Pre-populate a record producer with values from a previous form entry

Katie A
Mega Guru

I want to create a series of record producers, the second record producer must have values pre-populated from the first record producer.

Here is the requirement:

The first record producer has one text field for "hostname". When the user submits that record producer, it runs a simple Test Server Alive workflow. If the desired hostname entered is valid, a set of additional questions must be asked.

So, a second record producer should be pulled up with the hostname pre-populated and the remaining questions. The second record producer will create a catalog item request.

How can I redirect the user to the second record producer with the hostname pre-populated from the first form? Should I do this in a workflow or with the SetRedirect() in a script?

Please let me know how I can achieve this. The general requirements are outlined in this other post here and I have been trying many different techniques to solve this issue.

https://community.servicenow.com/message/892860?et=watches.email.thread#892860

1 ACCEPTED SOLUTION

Brad Tilton
ServiceNow Employee
ServiceNow Employee

When you do your redirect you can pass some url parameters, then run an onload client script on your second record producer that will read those and populate the necessary variables.



Parse URL Parameters in a Client Script - ServiceNow Guru



I think the difficult part will be actually setting the url redirect as you'll need to wait until your workflow completes.


View solution in original post

4 REPLIES 4

Brad Tilton
ServiceNow Employee
ServiceNow Employee

When you do your redirect you can pass some url parameters, then run an onload client script on your second record producer that will read those and populate the necessary variables.



Parse URL Parameters in a Client Script - ServiceNow Guru



I think the difficult part will be actually setting the url redirect as you'll need to wait until your workflow completes.


williamsun
Mega Guru

What I would do is simply a Catalog Item that has all the field, hostname and the others as well.


Then you make all fields except the hostname invisible through a Catalog UI Policy.


Once the hostname is populated, you run a Catalog Client Script that does the validation (not sure if you can do this here) and if true, shows the rest of the fields for the user to complete this.


Hi William, The biggest issue I am running into is running the validation via the client script. If a client script has to wait for the AJAX call and then wait for the workflow activity to complete and return the result value, it will take a long time. This is the issue I was trying to avoid by having two record producers.



Script Include WAIT for a workflow context to complete


Run Workflow from Client Script then retrieve value BACK before submit


In this case you can make the first task trigger a true-false field or end in a specific "state" so that you know if the hostname was valid.


Then for the second record producer, you add a field that looks up in the first task's table, you can make it lookup in the hostname field or even the task's number field, either way, make sure you restrict it so that only those that are flagged as finished "valid" appear.


Then a client script could populate fields from this referenced record.