A way to auto populate fields based on another field selection without using dotwalking

Mitch Moses
Giga Expert

I am looking for a way to fill in fields even if they are already filled in without using dot walking. I'm not sure if there's another alternative or not. Looking for any ideas that anyone might have

1 ACCEPTED SOLUTION

Brent Sutton
Mega Sage

Hi Mitch,

You can set these fields using an onChange client script with the "Configuration item" (cmdb_ci) as the field name.

The following code is just an example of how you can retrieve data from the CI and populate the incident table using getReference:

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
	if (isLoading || newValue === '') {
		return;
	}
	var ci = g_form.getReference("cmdb_ci", callBack);
}	
function callBack(ci){

	if (ci) {
		var cusSysId = ci.assigned_to; //assigned to user on the ci record
		var locSysId = ci.location; //ci location

		g_form.setValue("caller_id", cusSysId); //set caller with the user assigned to the ci
		g_form.setValue("location", locSysId); //set location based on ci location
	}
}

I personally prefer GlideAjax which has a client and server requirement to work. The benefit of using GlideAjax is that it only returns the data that you need rather than the whole record.

Let me know if this answered your question.

Brent

P.S. If my suggestion helped then please mark as helpful and/or correct so other community members can benefit from this information.

View solution in original post

3 REPLIES 3

Mitch Moses
Giga Expert

I am attempting to auto populate the customer, location, etc. based upon configuration item selection. 

Mitch Moses
Giga Expert

..updating because this just got approved for posting 

Brent Sutton
Mega Sage

Hi Mitch,

You can set these fields using an onChange client script with the "Configuration item" (cmdb_ci) as the field name.

The following code is just an example of how you can retrieve data from the CI and populate the incident table using getReference:

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
	if (isLoading || newValue === '') {
		return;
	}
	var ci = g_form.getReference("cmdb_ci", callBack);
}	
function callBack(ci){

	if (ci) {
		var cusSysId = ci.assigned_to; //assigned to user on the ci record
		var locSysId = ci.location; //ci location

		g_form.setValue("caller_id", cusSysId); //set caller with the user assigned to the ci
		g_form.setValue("location", locSysId); //set location based on ci location
	}
}

I personally prefer GlideAjax which has a client and server requirement to work. The benefit of using GlideAjax is that it only returns the data that you need rather than the whole record.

Let me know if this answered your question.

Brent

P.S. If my suggestion helped then please mark as helpful and/or correct so other community members can benefit from this information.