Interview questions

chandan86patra
Tera Contributor

Hi All,

 

I have some doubts related to interview questions :

 

1. How to pass the current sysid or URL in the onload client script.

2. You write a display business rule and script include; which one will go performance- and scripting-wise?

3. Have you created any custom actions in the flow designer? Give us one example.

 

Can anyone help relate this question it will be helpful for me 

 

Thanks and Regards,

Chandan Patra

2 REPLIES 2

Shivalika
Mega Sage

Hello @chandan86patra 

 

1)

var url = top.location.href;
var sys_id = new URLSearchParams(url).get("sysparm_id"); //this contains sys_id of current record

 

2)Performance wise Script include is better, Scripting wise BR is better. Explanation below - 
Script include is always preferred over Display BR. Because firstly DIsplay BR are high in execution engine and run first, secondly display BR will run everytime the form is loaded. This will cause a lot of performance issues. 

 

Script includes on the other hand are dynamic and will be called only if you want it to based on the parameters you pass. So performance wise this is better. 

 

With the aspect of Scripting - obviously display BR requires less scripting , only put the content in g_scratchpad object and pass it, same retrieve the content on client side using g_scratchpad.VARIABLE NAME. So scripting wise, BR is better. On the other hand, For script include you need to initialize "GlideAjax" Object, create functions, pass parameters and retrieve the answer in XML. 

 

3)Yes, custom actions are very common use case for flow designers. Most frequently they are used in Integrations. Where you are passing some value from the flow designer as input to action, performing some action on it and returning output. 

 

They are also frequently used in activities which you need to repeat again and again. May be you are taking some date input and performing a lot of changes and calculations and returning it. And this same operation you have to perform on multiple other flows, then create an action. 

 

I hope this answers your queries. 

 

Kindly mark my answer as helpful and accept solution if it helped you in anyway. This will help me be recognized for the efforts and also move this questions from unsolved to solved bucket. 

 

Regards,

 

Shivalika 

 

My LinkedIn - https://www.linkedin.com/in/shivalika-gupta-540346194

 

My youtube - https://youtube.com/playlist?list=PLsHuNzTdkE5Cn4PyS7HdV0Vg8JsfdgQlA&si=0WynLcOwNeEISQCY

venkat venky
Tera Contributor

answers,

1) 

function onLoad() {
// Get sys_id from the URL
var sysId = g_form.getUniqueValue();
}

-------------------------------------------------------------------
function onLoad() {
var currentUrl = window.location.href;
}

------------------------------------------------------------------------------

2) comparing display business rule and script include in terms of performance and scripting wise, depends on how we are going to use them as they are used for different purpose.

=> Display business rule use to get the data to display on the form, when form is loaded. Limited in scope—meant for passing small bits of data efficiently.

=> Script include is More scalable. Logic can be reused instead of duplicated. Can be called from Business Rules, UI Actions, Workflows, Client Scripts (via GlideAjax), etc.

 

Performance wise script include keeps logic modular, easy to optimize. where as scripting side less coding be used for Display business rule.

 

3) Yes, custom actions are common for flow designer, I have created an event for the custom actions, where inputs be given on the action with event name, parameter 1 and 2, record etc. with simple logic in action script as gs.eventqueue(inputs);.

In flow we can add this event by calling the event name which we already saved in event registry and with associated fields. The expected out put be seen in the Execution part with target table.

 

I hope this answers will satisfied your queries, 

 

If it helped you, Kindly mark my answer as helpful and accept solution . This will help me to give better solutions for upcoming  questions and helps others.