Where is related list data stored?

danmadzia
Tera Contributor

Here is the scenario:

In Stories, in the Related Links area, I have some related lists: Affected CI's, Change Requests, etc.

I can do the usual Edit or New to add records to - lets use Change Request for example.   No problem.

I have created a UI action to Create a Change Request from Story which works just fine.  

The problem is: How do I add the change request number (or sys_id) to the Change Requests Related List in my UI Action script?

I cannot find where that data is stored.

Thanks!

Dan

1 ACCEPTED SOLUTION

  var changeRequest = ChangeRequest.newNormal();


  changeRequest.setValue("short_description", current.short_description);


  changeRequest.setValue("description", current.description);


  changeRequest.setValue("cmdb_ci", current.cmdb_ci);


  changeRequest.setValue("priority", current.priority);


  changeRequest.setValue("sys_domain", current.sys_domain);


  changeRequest.setValue("company", current.company);


  changeRequest.setValue("parent", current.sys_id);   // Adds to related records


  changeRequest.insert();



Thanks


Please Hit like, Helpful or Correct depending on the impact of the response


View solution in original post

10 REPLIES 10

Alikutty A
Tera Sage

Hi Dan,



In the UI Action, please add the following line before you insert the change.



record.parent = current.sys_id;   // The record is your glide record variable on change_request.



Thanks


Please Hit like, Helpful or Correct depending on the impact of the response


The parent field on change request table relates to your story table and you need to update this field for the related change request to be displayed under the list. Please see the filter condition on the related list.



find_real_file.png



Thanks


Please Hit like, Helpful or Correct depending on the impact of the response


That doesn't seem to work.   The UI Action just flashes the screen and does not create the change control anymore.   Here is my script:


(function(current, previous, gs, action) {


  var changeRequest = ChangeRequest.newNormal();


  changeRequest.setValue("short_description", current.short_description);


  changeRequest.setValue("description", current.description);


  changeRequest.setValue("cmdb_ci", current.cmdb_ci);


  changeRequest.setValue("priority", current.priority);


  changeRequest.setValue("sys_domain", current.sys_domain);


  changeRequest.setValue("company", current.company);


  record.parent = current.sys_id;   // Adds to related records


  changeRequest.insert();



  current.rfc = changeRequest.getGlideRecord().getUniqueValue();


  current.update();



  gs.addInfoMessage("Change " + changeRequest.getValue("number") + " created");


  action.setRedirectURL(changeRequest.getGlideRecord());


  action.setReturnURL(current);



})(current, previous, gs, action);



Also, in the story, when looking at the Change Requests list, my Parent shows that Parent = {short description of story}


story.jpg


My parent is not (empty) by default?