Question
IT Solution Service
SG
Last activity: 23 Nov 2023 2:27 EST
Decimal field for dollar and million dollar
Hello,
My customer wants to create UI where user enters value based on million dollar.
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?
Regards,
-
Reply
-
Lesya Stienen Cloe Walker -
Share this page Facebook Twitter LinkedIn Email Copying... Copied!
Accepted Solution
Updated: 23 Nov 2023 2:27 EST
Pegasystems Inc.
JP
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.
1. Create a control and paste below snippet.
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.
1. 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)";
>
2. Apply the control to your Decimal property.
3. Below is the image of how it works.
Thanks,
Updated: 20 Oct 2023 4:59 EDT
Bits in Glass
IN
@CloeW938 edit input should be working for your scenario. Edit input is used to modify the value entered by user.
Please check below url for a sample edit input scenario
https://support.pega.com/question/edit-input
About Edit input
https://docs-previous.pega.com/reference/87/about-edit-input-rules
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.
IT Solution Service
SG
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.
Regards,
Bits in Glass
IN
@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.
Tekclan Software Solutions
IN
Hi @CloeW938,
Approach 1: Create a HTML control. In HTML control we can be able to control how we want to display, also how we want to store also.
Approach 2(Preferred): In post Processing data transform just multiply with million to have the correct value.
Thanks.
IT Solution Service
SG
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?
Regards,
Accepted Solution
Updated: 23 Nov 2023 2:27 EST
Pegasystems Inc.
JP
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.
1. Create a control and paste below snippet.
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.
1. 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)";
>
2. Apply the control to your Decimal property.
3. Below is the image of how it works.
Thanks,