The Zurich release has arrived! Interested in new features and functionalities? Click here for more

Performance difference of client script vs auto-populate?

Jacob Saaby Nie
Tera Contributor

Hi everyone.

 

Have you, or do you know of anyone who did, done a performance comparison of:

 

  1. Auto-populating a field via a client script that uses a callback VS
  2. Out of the box auto-populate on a field

Something like this code for the client script (I anonymized the field/variable names).

 

 

function onChange(control, oldValue, newValue, isLoading) {
	if (isLoading) {
		return;
	}
	if (newValue == '') {
		g_form.clearValue('field');
        return;
    }
	
	//Type appropriate comment here, and begin script below
	var userInfo = new GlideRecord("sys_user");
	userInfo.addQuery("sys_id", g_form.getValue('field'));
	userInfo.query(userCallBack);

	function userCallBack(userInfo) {
		if (userInfo.next()) {
			g_form.setValue('field',userInfo.field);
		}
		
	}
}

 

 

I would love to move to the out of the box auto-populate, but the only pro argument I have is making it easier across the team not having to deal with code they don't understand.

 

Which is faster? Or are there other considerations that make one better to use than the other?

1 ACCEPTED SOLUTION

PrashantLearnIT
Giga Sage

Hi @Jacob Saaby Nie 

 

Definitely, the fastest one is 

  1. Out of the box auto-populate on a field
********************************************************************************************************
Please appreciate the efforts of community contributors by marking the appropriate response as the correct answer and helpful. This may help other community users to follow the correct solution in the future.

********************************************************************************************************
Cheers,
Prashant Kumar
ServiceNow Technical Architect


Community Profile LinkedIn YouTube Medium TopMate
********************************************************************************************************

View solution in original post

1 REPLY 1

PrashantLearnIT
Giga Sage

Hi @Jacob Saaby Nie 

 

Definitely, the fastest one is 

  1. Out of the box auto-populate on a field
********************************************************************************************************
Please appreciate the efforts of community contributors by marking the appropriate response as the correct answer and helpful. This may help other community users to follow the correct solution in the future.

********************************************************************************************************
Cheers,
Prashant Kumar
ServiceNow Technical Architect


Community Profile LinkedIn YouTube Medium TopMate
********************************************************************************************************