Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

Concatenation in breakdown script

venori26
Tera Contributor

my breakdown script is as below:

 

current.vulnerability.sys_id;

 

how do I concatenate a letter 'a' to this?

9 REPLIES 9

Hi @venori26 ,

 

Please go through this below article 

PA - Creating Breakdown script 

Script Mapping  

 

It seems like you need to write something like

var concatenatedString()=function(){
var val="";
var gr=new GlideRecord('sn_vul_third_party_entry');
//below is important query that decides from 'sn_vul_third_party_entry' table which record has to be fetched.
gr.addQuery('vulnerability',current.sys_id); //here vulnerability is assumed as field from 'sn_vul_third_party_entry' table and fetching record from this table
gr.query();
//Based on multiple record or single record
if(gr.next()){
val=gr.id+" - "+gr.summary;
}
return val;
};
concatenatedString();

 

 

 

Thanks,
Bhimashankar H

 

-------------------------------------------------------------------------------------------------
If my response points you in the right directions, please consider marking it as 'Helpful' & 'Correct'. Thanks!

Hello Sir,

 

Good morning/Evening,

Thank you so much for the response and script.

 

In this part of the script above -

gr.addQuery('vulnerability',current.sys_id); //here vulnerability is assumed as field from 'sn_vul_third_party_entry' table and fetching record from this table

 

vulnerability is a reference field in parent table sn_vul_vulnerable_item. using 'current' was giving me an error. so I modified the script a little by removing the current and modifying the line as below:

 

gr.addQuery('id',sys_id);
 
Attaching the script window and error
venori26_0-1757395662015.png

 

venori26_1-1757395730351.png

 

It won't work just using the sys_id @venori26 , you need to give the reference record as a filter.

 

did you go through the references I mentioned, you can make necessary changes by understanding what could work in your case from references.

 

As per the document it says the current refers to current record, it should not give any errors as such. Ensure you are using the correct relations between tables.

 

Please refer this post

Breakdown script question 

How can I create a breakdown by task type on the Time Card table 

and

Scripting in PA 

 

Above post has your questions answer

 

Thanks,
Bhimashankar H

 

-------------------------------------------------------------------------------------------------
If my response points you in the right directions, please consider marking it as 'Helpful' & 'Correct'. Thanks!

venori26
Tera Contributor

venori26_0-1757318053499.png

 

I used above code but it is gave me an error: Error during JavaScript evaluation: Not all references of "current" are passed in by "arguments" script: var id = current.getValue('vulnerability'); // sys_id as string
var val = id + "a"; // concatenate 'a'
val;

I tested the code from the link you shared for my scenario: it worked without concatenation but giving zero breakdown elements with concatenation:

 

working script:

var concatenatedString=function(){
var gr=new GlideRecord(current.vulnerability);
return gr;
};
concatenatedString();
 
Not working script (script is running without error and giving score but not breakdown element):
 
var concatenatedString=function(){
var gr=new GlideRecord(current.vulnerability);
return gr + "-" +'a';
};
concatenatedString();