How to Auto-populate field value in the related list form

Vivek13
Tera Contributor

Hi,

I have created a string field WOT number in the cmdb_ci_storage_device form and I have brought the related list storage device in the work order task, When I click on new in the storage device related list of the work order task form, the current number of the work order task must be populated in the WOT number field which is available in cmdb_ci_storage_device form. How can I do this?

1 ACCEPTED SOLUTION

Hi Vivek,

I would recommend using a reference field instead of string field; in that way the relationship would come automatically and the parent field would be set automatically

Mark Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur

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

View solution in original post

8 REPLIES 8

Hi Vivek,

as per your screenshot the WOT number shows an ref icon indicating some record information in it; can you check by clicking the 'i' icon what is shows

Regards

Ankur

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

Hi,

Yes it is showing the current work order task record.

Thanks it worked now

Adrian Ubeda
Mega Sage
Mega Sage

Hi, 

For getting this related WOT you should create a clientScript onLoad on the form that you are targeting and use scratchpad variables from Bussines rule, I give some example that I used:

// Business rule on display advanced
var sourceURL = gs.action.getGlideURI().getMap().get('sysparm_collection');
	var aux= '';
	if(sourceURL == "table_you_want"){
		id = gs.action.getGlideURI().getMap().get('sysparm_collectionID');
		g_scratchpad.wmTask = aux;
	}
//Client script onLoad
function onLoad() {

	if(g_form.isNewRecord()){		
		g_form.setValue('wot_referenced',g_scratchpad.wmTask);
	}

}

If it was helpful, please give positive feedback.

Thanks,

If it was helpful, please give positive feedback! ✔
☆ Community Rising Star 22, 23 & 24 ☆