- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-15-2022 12:33 AM
Hi,
I've 3 fields where I need the sum of 2 fields to be displayed in 3rd field.
As per the attached image, I want to add the value of 500 and 80 and display the sum value in "Productivity - Test Design" field which is read only field. I know we have to do some scripting under UI Policy for that read only field, but my Code is NOT working. Can someone help me with this? or do we have any other method to do this?
Thank you so much in advance, for helping me.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-15-2022 01:33 AM
Hi,
is the field read-only from dictionary level?
You cannot do this from UI if the field is read-only; please use before update business rule on your table
Script:
(function executeRule(current, previous /*null when async*/) {
// Add your code here
current.u_field3 = parseInt(current.u_field1) + parseInt(current.u_field2); // give correct field names here
})(current, previous);
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-15-2022 12:44 AM
Hello,
You can write a after Update BR on your table with below conditions and script
condition:
Manual test cases designed changes or test design effort changes
Script
var gr = new GlideRecord('your table name');
gr.addQuery('sys_id',current.sys_id);
gr.query();
if(gr.next())
{
var total = parseInt(gr.manual test cases designed field back end name)+parseInt(gr.test design effort backend name);
gr.setValue(productivity-test design field name,total)
gr.update();
}
Please mark my answer correct if it helps you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-15-2022 12:44 AM
Hi,
you can use "Function field".
see @ https://docs.servicenow.com/bundle/sandiego-platform-administration/page/build/platform-functions/concept/platform-support-functions.html
Thanks,
Sanjeev kumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-15-2022 01:03 AM
Hi Ashok,
You can use function field on "Productivity - Test Design" field as shown below,
However, this shows result only when you save the form. If you want result to be shown in UI as soon as value is changed then you will have to write onchange client script on both fields (Manual test cases designed and Number of manual test steps).
Let me know if you have any further queries.
Please mark this as Correct or Helpful if it helps.
Thanks and Regards,
Abhijit
Community Rising Star 2022
Regards,
Abhijit
ServiceNow MVP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-15-2022 01:33 AM
Hi,
is the field read-only from dictionary level?
You cannot do this from UI if the field is read-only; please use before update business rule on your table
Script:
(function executeRule(current, previous /*null when async*/) {
// Add your code here
current.u_field3 = parseInt(current.u_field1) + parseInt(current.u_field2); // give correct field names here
})(current, previous);
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader