- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-17-2023 06:19 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-17-2023 06:32 AM
Then you can write one line of code as below in before insert BR:-
current.youCustomField=current.yourMainField;
Please Mark My Response as Correct/Helpful based on Impact
Regards,
Gunjan Kiratkar
2X ServiceNow MVP
Community Rising Star 2022
Youtube : ServiceNow Guy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-17-2023 06:32 AM
Then you can write one line of code as below in before insert BR:-
current.youCustomField=current.yourMainField;
Please Mark My Response as Correct/Helpful based on Impact
Regards,
Gunjan Kiratkar
2X ServiceNow MVP
Community Rising Star 2022
Youtube : ServiceNow Guy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-17-2023 06:33 AM
Hi @Anmol Soldier ,
You can use this sample script :
(function executeRule(current, previous /*null when async*/) {
var gr = new GlideRecord("u_hardware_expensed_asset_list");
gr.initialize();
gr.<field_name1> = current.<field_name1>;
gr.<field_name2> = current.<field_name2>;
gr.<field_name3> = current.<field_name3>;
//repeat above for all the required fields
gr.update();
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-17-2023 06:35 AM
Hi Anmol,
Based on your description, this is pretty simple. Assuming that both fields are part of the same record, your rule would look like this:
current.setValue(<custom field to be updated>, <existing field with the value>);
If you need to put or get the value from some other record, just declare the GlideRecord and position before setting the value.
Because you are doing this in a Before rule, do not include current.update() in your rule otherwise you risk crating an endless loop.
:{)
Helpful and Correct tags are appreciated and help others to find information faster