Auto populate fields through UI Action

srinathpatel
Kilo Contributor

Parent Table parameters passing to child table through   UI Action(Without Child Record Insert passing through   URL ).

  • Test Plan (Parent table) 2 fields Short description and instructions are Auto   Map to Defects (Child table)   fields Short description and description.

UI Action:

Name:My Defect

Table:Test Plan[tm_test_plan]

Form Button:True

On click:open_defect();

Script:

function open_defect(){

var shortdesc = g_form.getValue("short_description");

var instructions = g_form.getValue("instructions");

var URL = "/nav_to.do?uri=rm_defect.do?sys_id=-1%26sysparm_query=short_description="+shortdesc+"^description="+instructions;

top.location.href= URL;

}

find_real_file.png

  • If click on my defect button   its Auto populate   2 fields to without Insert child record .

find_real_file.png

Thanks,

Srinath Patel

5 REPLIES 5

Chuck Tomasi
Tera Patron

I wouldn't use a client script do this. I don't see any need for it based on your example, but I don't have all the requirements. When possible, keep your UI actions server side. Something like this (warning, untested code).

var shortdesc = current.getValue("short_description");
var instructions = current.getValue("instructions");

var URL = "rm_defect.do?sys_id=-1&sysparm_query=short_description="+shortdesc+"^description="+instructions;

var enc = GlideStringUtil.urlEncode(URL);

action.setRedirectURL(enc);

 

SR2
Tera Contributor

When creating a new record in incident table, If the record number matches with the existing records in incident table, and when we click on the UI action button, the form should be auto filled with the values in the matched incident record. So, how can we achieve this. Any clues....?

 

Hi Chuck,

 

In this same method, how do I populate a field which is not the in the form? for eg: 'parent' field of Incident.
And the rest of the condition remains the same (I dont want the form to be saved).

 

Best Regards,

Swarnadeep Nandy

Kunal Varkhede
Tera Guru

Hi srinathpatel,

Try below script in UI action on server side.

var gr = new GlideRecord('defect_table');
gr.initialise();
gr.description = current.instruction;
gr.short_description = current.short_description;
gr.insert();
action.setRedirectURL(current);

I hope it also help you.

Thanks and Regards,

Kunal.