Questions on client scripts

Shaik22
Tera Expert

Hello,

Please provide the answers of below questions.

 

1.Syntax for call back function,how will pass parameters?

2.Implication of Glide Aggregate API.

3.If we create a on load client script and before Business rule on load,which one will run first,and why?

4.Explain scripting layers in servicenow?

5.Can we write Global client script?

6.What is global client script,uses and drawbacks of global client script.

7.Difference between client script and catalog client script?

8.How do you receive as response in client script?

9.Difference between global vs scoped client script.which one is suggested approach?

10.Difference between glide record vs getReference  or getReference vs getValue?

11.Limitations of oncelledit type?

 

1 ACCEPTED SOLUTION

Kalyani Jangam1
Mega Sage
Mega Sage

Hi @Shaik22 

 

1.Syntax for call back function,how will pass parameters?

We can't dot walk on client script direct so you have to use callback function. 

var volume = g_form.getReference("csv_tenant_request", setCurrentValues);

 

function setCurrentValues(test){

// Logic in callback function

}

2.Implication of Glide Aggregate API.

GlideAggregate is part of the Server API.   Unlike GlideRecord, it has no client side equivalent.   But you can make an GlideAjax call to perform the aggregate and return it. (GlideAjax - ServiceNow Wiki )

 

3.If we create a on load client script and before Business rule on load,which one will run first,and why?

First run onload client at the time of form loading and if you save the record then before saving before business rule will trigger

 

4.Explain scripting layers in servicenow?

Server side=> Business rule, script include,schedule job

Client side=> client script, UI policy,UI script

 

5.Can we write Global client script?

Yes, If you make a client script global it will be only able to operate on an application in the global scope. If you're working in a scoped app you will need to set it the application of your client script to the name of your scoped application.

 

6.What is global client script,uses and drawbacks of global client script.

Marking a Client Script as "Global" will make is available to ALL Cient Scripts.

NOTE:
There is a technical drawback on doing so. Because it is available for all Client Scripts, it will be INCLUDED and transferred to EACH single Client Page shown in your Web-Browser, which also blows up your volume of data, that needs to be transferred for each opened page.

That will slow up your overall performance for end-users.

So, keep an eye on WHAT you put as "global". Use that VERY rare and only place code there, which is REALLY needed EVERYWHERE!!!

 

7.Difference between client script and catalog client script?

Client Scripts and catalog Client Scripts are virtually the exact same sort of script.The differences are that client scripts execute against a form with a certain type of record, whereas catalog Client Scripts execute against a certain catalog item or variable set within a catalog item.

 

8.How do you receive as response in client script?

By using GlideAjax we received response

 

9.Difference between global vs scoped client script.which one is suggested approach?

Global used in global application and scoped used in application scope As per requirement we can use this client script.

 

10.Difference between glide record vs getReference  or getReference vs getValue?

getReference return value from callback function. GlideRecord is used to interact with servicenow database from script and getValue used to take value from any field.

 

11.Limitations of oncelledit type?

onCellEdit will work only on list view while change the values in a list. We can not use in form related operation.

 

 

Please check and Mark Helpful and Correct if it really helps you.

 

View solution in original post

1 REPLY 1

Kalyani Jangam1
Mega Sage
Mega Sage

Hi @Shaik22 

 

1.Syntax for call back function,how will pass parameters?

We can't dot walk on client script direct so you have to use callback function. 

var volume = g_form.getReference("csv_tenant_request", setCurrentValues);

 

function setCurrentValues(test){

// Logic in callback function

}

2.Implication of Glide Aggregate API.

GlideAggregate is part of the Server API.   Unlike GlideRecord, it has no client side equivalent.   But you can make an GlideAjax call to perform the aggregate and return it. (GlideAjax - ServiceNow Wiki )

 

3.If we create a on load client script and before Business rule on load,which one will run first,and why?

First run onload client at the time of form loading and if you save the record then before saving before business rule will trigger

 

4.Explain scripting layers in servicenow?

Server side=> Business rule, script include,schedule job

Client side=> client script, UI policy,UI script

 

5.Can we write Global client script?

Yes, If you make a client script global it will be only able to operate on an application in the global scope. If you're working in a scoped app you will need to set it the application of your client script to the name of your scoped application.

 

6.What is global client script,uses and drawbacks of global client script.

Marking a Client Script as "Global" will make is available to ALL Cient Scripts.

NOTE:
There is a technical drawback on doing so. Because it is available for all Client Scripts, it will be INCLUDED and transferred to EACH single Client Page shown in your Web-Browser, which also blows up your volume of data, that needs to be transferred for each opened page.

That will slow up your overall performance for end-users.

So, keep an eye on WHAT you put as "global". Use that VERY rare and only place code there, which is REALLY needed EVERYWHERE!!!

 

7.Difference between client script and catalog client script?

Client Scripts and catalog Client Scripts are virtually the exact same sort of script.The differences are that client scripts execute against a form with a certain type of record, whereas catalog Client Scripts execute against a certain catalog item or variable set within a catalog item.

 

8.How do you receive as response in client script?

By using GlideAjax we received response

 

9.Difference between global vs scoped client script.which one is suggested approach?

Global used in global application and scoped used in application scope As per requirement we can use this client script.

 

10.Difference between glide record vs getReference  or getReference vs getValue?

getReference return value from callback function. GlideRecord is used to interact with servicenow database from script and getValue used to take value from any field.

 

11.Limitations of oncelledit type?

onCellEdit will work only on list view while change the values in a list. We can not use in form related operation.

 

 

Please check and Mark Helpful and Correct if it really helps you.