is there a way to connect the sys_id of a record producer with the sys_id of the record produced?

patricklatella
Mega Sage

I'm trying to figure out a way to connect the sys_id of a request record to the sys_id of the record producer that created it.

is that possible?

1 ACCEPTED SOLUTION

Michael Fry1
Kilo Patron

In the script field of the record producer you can add code to populate a field with the information you want. For example, say you have a field RC on incident table, where RC is a reference to the record producer table. In the script field in the RC, you can use current. u_rc = 'sys_id' of record producer.


View solution in original post

11 REPLIES 11

patricklatella
Mega Sage

now as well oddly, if my filter is down to one variable, it works properly.



find_real_file.png



here's the script:



var ID;



switch (current.template.toString()){


case 'db5f551b4fca6e0089c7029d0210c7d9'://sys_id of Contract template


ID = '3e4c5d974fca6e0089c7029d0210c79d';//sys_id of Contracts record producer


break;



case '7481334c4f3db60089c7029d0210c72d'://sys_id of Cost Accounting template


ID = '3891bb4c4f3db60089c7029d0210c725';//sys_id of Cost Accounting record producer


break;



case 'b7fe73444f7db60089c7029d0210c72a'://sys_id of Business Development template


ID = '400f73444f7db60089c7029d0210c72c';//sys_id of BD PM record producer


break;


}



var url;


url = '/com.glideapp.servicecatalog_cat_item_view.do?sysparm_initial=true&sysparm_id=';//url to build string upon



var gr = new GlideRecord("question_answer");//table to query


gr.addQuery('table_sys_id',current.sys_id);//field to query


gr.query();//execute the query



while (gr.next()){


if (gr.question.name == 'project_type')// filtered to only variable



url = url+ID+'&sysparm_'+gr.question.name+'='+gr.value;



}



gs.addInfoMessage('+++My URL is '+url);//this here for testing purposes


action.setRedirectURL(url);


patricklatella
Mega Sage

and if I change to more than one filter,



if (gr.question.name == 'project_type' || gr.question.name == 'request_type')



then it does this, where it adds the var "ID" (which here is a sys_id) in more than one spot, but not at the end.



find_real_file.png