Populate field value from another table

WaledBajukhaif
Tera Expert

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.

 
Any help/suggestions?
2 REPLIES 2

Bert_c1
Kilo Patron

You should post your BE definition and script if present, to get folks here to comment.

 

10-tips-for-writing-a-quality-community-question

 

Amit Gujarathi
Giga Sage
Giga Sage

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