Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to Create m2m record?

Milan Chugh
Tera Contributor

I have created a new m2m table on the rm_release table to create change_request table. Created a new UI action which will create the change record, but not inserting a record in the m2m table to show relationship link between them.
Is there a way to get the sys_id of the change request in the UI action to insert a record as we have the parent sys_id of the release.

Script using: 

(function(action) {
var uri = action.getGlideURI();
uri.deleteParmameter('sysparm_referring_url');
uri.deleteMatchingParameter('sysparm_list_');
uri.deleteMatchingParameter('sysparm_record_');
uri.deleteParmameter('sys_is_list');
uri.deleteParmameter('sys_is_related_list');
uri.deleteParmameter('sys_submitted');
uri.deleteParmameter('sysparm_checked_items');
uri.deleteParmameter('sysparm_ref_list_query');
uri.deleteParmameter('sysparm_current_row');
uri.deleteMatchingParameter('fancy.');
uri.deleteMatchingParameter('sys_rownum');
uri.deleteMatchingParameter('sysparm_encoded');
uri.deleteMatchingParameter('sysparm_query_encoded');
uri.deleteParmameter('sysparm_refer');

uri.set("sysparm_referring_url", encodeURIComponent(uri.toString()));

var stackUrl = uri.get("sysparm_collection") + ".do?sys_id=" + uri.get("sysparm_collectionID");
uri.set("sysparm_stack", stackUrl);

action.setRedirectURL("new_change_redirect.do?&sn_new_change_referrer=" + encodeURIComponent(uri.toString("")));


})(action);

 

0 REPLIES 0