The CreatorCon Call for Content is officially open! Get started here.

How to update new UI action in the related list and set the sys id to the current form in the field

Nagasri
Tera Expert

I have created a new UI action in the related list, to create a new record on rm_story table. After creation, it should added to related story field on the parent table record. How to get the submitted sys_id in UI action to set on the parent table record. Please help me on this.

 

@Ankur Bawiskar 

 

var uri = action.getGlideURI();
var path = uri.getFileFromPath() + '';
path = path.substring(0, path.length - 5) + '.do';

uri.set('sys_id', '-1');
uri.set('sys_target','rm_story');
uri.set('sysparm_collection_related_field','u_related_story');

path = checkWizard(uri, path);

if (path)
   action.setRedirectURL(uri.toString(path));

action.setNoPop(true);

function checkWizard(uri, path) {
   var already = uri.get('WIZARD:action');
   if (already == 'follow')
   return null;
   
   var wizID = new GlideappWizardIntercept(path).get();
   if (!wizID)
      return path;
   
   uri.set('sysparm_parent', wizID);
   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.set('sysparm_referring_url', uri.toString());
   uri.deleteMatchingParameter('fancy.');
   uri.deleteMatchingParameter('sys_rownum');
   uri.deleteMatchingParameter('sysparm_encoded');
   uri.deleteMatchingParameter('sysparm_query_encoded');
   uri.deleteParmameter('sysparm_refer');

   return 'wizard_view.do';
}
4 REPLIES 4

Ankur Bawiskar
Tera Patron
Tera Patron

@Nagasri 

Did you check any OOB ui action for this?

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi @Ankur Bawiskar ,

 

That script is from oob ui action but we need to set the created record sysid to parent table field. This is our customization.

@Nagasri 

if you are creating record on child table then you store the parent sysId in child record

why should it be reverse?

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Nagasri
Tera Expert

The actual requirement is a list type field records should show on the related list, then we can hide the field and follow only related list. so we are creating a new ui action to add a new record on the list type field