For example, user enters 10 in the field as above, then its actual value is 10,000,000. They want to store 10,000,000 to the database, not 10. We do not want to create another field to store two values as it may get programmatic and lead to errors. Is there any OOTB way to handle this with a single field?
If you want the value to be changed only post submission of the assignment, then in the post data transform you can convert the user entered value to your needed value.
Edit Input is not appropriate because every time it multiplies the value. If you save the work object twice, the value is multiplied twice. Post Data Transform is also inappropriate because if the work object is routed back and submitted one more time, it gets multiplied once more.
Approach 2 is not appropriate because if work object is rejected by approver and routed back again, it goes through the Data Transform again which leads to unnecessary multiplication. I would like to know how I can implement Approach 1. Does anyone have a sample code?
@CloeW938 okay in the post DT approach, we can use a flag. Whenever we do rerouting due to some reasons we will be maintaining a flag which would use to skip many unwanted steps which we already did. You can also use a similar flag to skip the rerun of this DT again, so this runs only once.
Meanwhile you can also try html control also suggested by Dhanasekhar.
I would not recommend that you use Data Transform with flag for multiplication as it is procedural. You can take two approaches.
(1) Create two properties. One for display and the other one for actual values. Use Declare Expression for the value synchronization. Having two properties are complex but they are auto-maintained and it should work stably.
(2) Create your own custom control to multiply the value by 1,000,000 on focusout event. You can follow the steps below.
Create a control and paste below snippet.
```
<script>
function validateNumeric(e)
{
if (!e) var e = window.event;
if (!e.which)
keyPressed = e.keyCode;
else
keyPressed = e.which;
if ((keyPressed >= 48 && keyPressed <= 57) || keyPressed == 8 || keyPressed == 9 )
{
keyPressed = keyPressed;
return true;
}
else
{
keyPressed = 0;
return false;
}
}
function multiple10000(e)
{
if (!e) var e = window.event;
e.target.value = e.target.value * 10000;
}
function devide10000(e)
{
if (!e) var e = window.event;
e.target.value = e.target.value / 10000;
}
</script>
```
<input size="7"
id="<pega:reference name="$THIS-DEFINITION(pyPropertyName)" /><%= tools.getParamValue("pega_RLindex") %>"
name="<pega:reference name="$this-name" />"
type=text
class="rightJustifyStyle"
value="<pega:reference name="$this-value" />"
maxlength="7"
onkeypress="return validateNumeric(event);"
onfocus = "devide10000(event)"
onfocusout="multiple10000(event)";
>