How to Get a Parent's Data to a New Record using a UI List Action

Joshua Cassity
Kilo Guru

We've run into an issue where we have a custom parent request form that has a related list and we'd like to add an action on that related list to create a new related record to this parent but copy over some of the parent's data over to the newly created record.

Ex. I have a Telecommunications Request Form that has basic data on it (Requested By, Telecommunication Closet Number, Type of Request, Service Code) and a related listing of Circuits that is derived based upon the Telecommunication's Closet Number.

I also have a Circuit table that has circuit specific data on it (Circuit Name, Power Type, Grid Name and also has a spot for the Telecommunication Closet Number for which it lives).

So in our case, Telecommunication Closet 45 already has three network circuits in it but I'd like to add a new circuit by letting the user press the New button on the related listing.

find_real_file.png

The problem is that when we create this new List UI Action, we can't seem to get the Closer # from the parent Request to put into the newly created child Circuit because we can't figure out how to collect and push that data to the new record. We believe this is because the action actually resides on the child Circuit form so anytime we do a 'current.' action it's not on the correct table and we end up getting this error message:

find_real_file.png

Can anyone provide us with a solution to actually be able to pull the parent's data into the child record using a List UI Action while allowing the user to input any other data into the new child record before it's saved to the database?

Any assistance would be greatly appreciated. Here is a copy of our logic so far:

// Open a new Glide Record in the circuit Table

var circuit = new GlideRecord('u_circuit');

circuit.initialize();

circuit.u_site_id = current.u_site_id; <<< Here's the Issue!

// Set the Form Fields Based Upon the NetTN Request Entered Data

circuit.insert();

action.setRedirectURL(circuit);

1 ACCEPTED SOLUTION

I think this is the issue.   Because it is a queried relationship there is no guarantee that it only has 1 parent so parent can't be provided.   Try this instead in a client ui action:



function insertNewCircuit() {


  document.location = 'u_circuit.do?sys_id=-1&sysparm_query=u_nettn_request=' + g_form.getUniqueValue() + '^u_site_id=' + g_form.getValue('location');


}



Screen Shot 2017-02-23 at 9.51.37 AM.png


View solution in original post

30 REPLIES 30

If you visit u_circuit, is there a new record there that is orphaned?   If so, I'm wondering if we are not setting something that is used by the related list to relate.


I checked and the last created record was 16 hours ago.



~ J ~


Any failures in the log?   I'm guessing the tests are run as admin so no ACL conflicts?


I get this entry:



org.mozilla.javascript.EcmaError: Cannot read property "u_site_id" from null


Caused by error in 6: circuit.u_site_id = parent.u_site_id;


7: circuit.u_nettn_request = parent.sys_id;


8:


9: // Set the Form Fields Based Upon the NetTN Request Entered Data



~ J ~


Can you share a screenshot of related list? I'm wondering if it is a typical reference created related list or is defined in the System Definition->Relationship.