Populate custom reference with document Id type field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2023 11:08 AM
Hello Experts,
On metrics form we have a ootb 'ID' field ('Document id' type) that stores the record to which the metric is belonged to. So, I have custom field created on it called 'Project'. So, If the 'ID' field has project record in it then I want to populate project field with same record as 'ID' field. How can I do that?
Thanks,
Rocky.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2023 12:59 AM
Hi Rocky
May one option could be to create a business rule where you query the project table for the "ID" record. If the record exist you set the project field in your metric record. Something like:
Filter conditions: ID changes
Script (Adapt script with your table/field values):
(function executeRule(current, previous /*null when async*/) {
var grMetric = new GlideRecord('metric');
if (grMetric.get(current.id.toString())){
current.project = current.id.toString();
} else {
current.project = '';
}
})(current, previous);
If the project field has to be populated immediately you could do the same with a client script glideajax call.
Best regards
Dominik