How to update next record field value based on previous record field

Deepak92
Tera Contributor

Hello Folks,

for the same ticket id if  record B has sub status as closed redirect i want to set  record A field value.

Any help would be highly appreciated 

Deepak92_1-1676566051961.jpeg

 

 

 

14 REPLIES 14

Sonu Parab
Mega Sage
Mega Sage

Hi @Deepak92 ,
Please follow below steps to achieve your requirement.
1] Create one After Update Business Rule.
2] In 'When to run'  Add condition as BizNow Sub Status  Changes to Closed - Redirect // Here BizNow Sub Status is your field.
3] Then you can take help of below script to set field value of set  record A.

(function executeRule(current, previous /*null when async*/ ) {

    var tacketId = current.ticket_id; //Give appropriate Ticke Id field name here

    var gr = new GlideRecord('incident'); // pass your approprite table name
    gr.addQuery('ticket_id', tacketId); // This query to find another same tickid record.
    // here ticket_id  backend name of Ticket Id field.
    gr.addEncodedQuery('biznow_sub_status_field=NULL'); //This query to check 'biznow_sub_status_field' empty or not.
    //Here biznow_sub_status_field  backend name of BizNow Sub Status field name.
    gr.query();
    if (gr.next()) {
        gr.biznow_sub_status_field = 'Closed - Redirect'; //pass your approriate field name for 'biznow_sub_status_field' and which value want to set.
        gr.update();
    }

})(current, previous);

 

If I could help you with your Query then, please hit the Thumb Icon and mark as Correct !!
Thank you

Hello@ sonu_parab

Thanks for your response .

No it will not worked . 

you don't understand the requirement . let me reframe it for same ticket id , based on Record B condition ( Status = closed redirect ) i need to set value for Record A field.

i'm pretty  sure we need to write a function in script include and call it from BR, its just am missing frame how to start .

 

 

 

 

 

Hi @Deepak92  Could you please share  what you have did so far in the BR, to complete your business requirement for what you are planning to achieve here.

Also share 1] Table Name  2] Ticket IdBizNow Sub Status  fields name and type.

Thank you

Hello @Sonu Parab ,

thanks for replying. 

Requirement is let suppose we already have records B in table , if record A came into table with same ticket id ,if its find Record B status is closed _redirect  , then i need to set Record A field value.