Populate field value from another table
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-24-2023 02:48 AM - edited 11-24-2023 05:38 AM
Hi all,
Senario: when a user submits a request form via Portal, it creates a request and task. once approved, it creates a story.
So in story record, I want to add a field shows who created the request.
I created a reference field "u_story_requester" in story table [rm_story]. and created an After Business Rule on [rm_story] table, but it didn't work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-24-2023 06:18 PM - edited 11-24-2023 06:20 PM
You should post your BE definition and script if present, to get folks here to comment.
10-tips-for-writing-a-quality-community-question
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-24-2023 08:39 PM
Hi @WaledBajukhaif ,
I trust you are doing great.
Here is a sample script you can use in your Business Rule:
(function executeRule(current, previous /*null when async*/) {
// Check if the current record is a new insertion
if (current.isNewRecord()) {
// Assuming there is a link/reference to the original request in the story record
// Replace 'original_request_field' with the actual field that links to the request
var originalRequestGR = new GlideRecord('request_table_name'); // Replace with your request table name
if (originalRequestGR.get(current.original_request_field)) {
// Set the 'u_story_requester' field with the requester from the original request
current.u_story_requester = originalRequestGR.requester_field; // Replace 'requester_field' with the field that stores the requester in the request record
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