AutoFill field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-15-2023 01:16 AM
Hi,
In the incident form,
if the "service" field is empty, should be filled in automatically when the "service offer" field is filled. If the "service" field is full - do not update it.
The value to be filled in the "service" field is the value in the "service offer" parent field (which is a reference to the record).
The record that is filled has a field called "parent" - this is the value that will enter the "service" field.
Thank,Shir
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-15-2023 01:47 AM
Could you please write me the script?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-15-2023 02:16 AM
(function executeRule(current, previous /*null when async*/) { if (current.service.nil() && !current.service_offer.nil()) { var parentRecord = new GlideRecord('parent_table'); if (parentRecord.get(current.service_offer.parent)) { current.service = parentRecord.getValue('parent_field'); } } })(current, previous);
Try this one!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-15-2023 03:09 AM
I need a solution with client script
The change should be made when filling out the form before saving
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-15-2023 02:10 AM
HI @Shir Sharvit ,
I trust you are doing great.
Please find the below script
(function executeRule(current, previous /*null when async*/) {
// Check if the 'service' field is empty
if (!current.service.nil()) {
return; // Exit if 'service' is not empty
}
// Check if 'service offer' is filled
if (current.service_offer.nil()) {
return; // Exit if 'service offer' is empty
}
// Get the 'parent' field value from the 'service offer' record
var serviceOfferGr = new GlideRecord('service_offer_table'); // Replace 'service_offer_table' with the actual table name
if (serviceOfferGr.get(current.service_offer)) {
var parentValue = serviceOfferGr.parent.getValue();
// Update the 'service' field with the 'parent' field value
current.service.setValue(parentValue);
current.update();
}
})(current, previous);
Was this answer helpful?
Please consider marking it correct or helpful.
Your feedback helps us improve!
Thank you!
Regards,
Amit Gujrathi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-15-2023 03:09 AM
I need a solution with client script
The change should be made when filling out the form before saving