- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2024 08:06 AM
I have a requirement to get the case ids enter in Case ID 1, CaseID 2.. Case ID 10 to connect case id column .
I could achieve this with below script. But now I need to include these conditions as well.
> In case duplicate value is added in case id 1(upto 10) , it should be cleared
> Also the duplicate shouldn't be present in connect case id
......
BR > before -update
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-01-2024 03:47 AM
Use OnSubmit client script instead of BR and refer following sample script
function onSubmit() {
//Type appropriate comment here, and begin script below
var allCasesArr = [];
for (i = 1; i <= 10; i++) {
var caseField = "u_caseid_" + i;
var caseVal = g_form.getValue(caseField).toString();
if (caseVal != "" && allCasesArr.indexOf(caseVal) != -1) {
g_form.addErrorMessage("Duplicate Case Entry");
g_form.clearValue(caseField);
} else if (caseVal != "")
allCasesArr.push(caseVal);
}
g_form.setValue('connect_case_ids_2', allCasesArr.toString());
}
Thanks,
Swathi Peddireddy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2024 08:34 AM
Hi,
There is the "ArrayUtil" script include that has several methods that can help you. Review that in you instance.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-30-2024 10:07 PM
Tried arrayutils and its not working

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2024 08:44 AM
@Anna_Servicenow Please update the script as follows and see if it works for you.
var myArray = [];
if (current.u_caseid_1 != '' && myArray.indexOf(current.u_caseid_1)==-1) {
myArray[0] = current.u_caseid_1;
}
if (current.u_caseid_2 != '' && myArray.indexOf(current.u_caseid_2)==-1) {
myArray[1] = current.u_caseid_2;
}
if (current.u_caseid_3 != '' && myArray.indexOf(current.u_caseid_3)==-1) {
myArray[2] = current.u_caseid_3;
}
if (current.u_caseid_4 != '' && myArray.indexOf(current.u_caseid_4)==-1) {
myArray[3] = current.u_caseid_4;
}
if (current.u_caseid_5 != '' && myArray.indexOf(current.u_caseid_5)==-1) {
myArray[4] = current.u_caseid_5;
}
if (current.u_caseid_6 != '' && myArray.indexOf(current.u_caseid_6)==-1) {
myArray[5] = current.u_caseid_6;
}
if (current.u_caseid_7 != '' && myArray.indexOf(current.u_caseid_7)==-1) {
myArray[6] = current.u_caseid_7;
}
if (current.u_caseid_8 != '' && myArray.indexOf(current.u_caseid_8)==-1) {
myArray[7] = current.u_caseid_8;
}
if (current.u_caseid_9 != '' && myArray.indexOf(current.u_caseid_9)==-1) {
myArray[8] = current.u_caseid_9;
}
if (current.u_caseid_10 != '' && myArray.indexOf(current.u_caseid_10)==-1) {
myArray[9] = current.u_caseid_10;
}
current.connect_case_ids_2 = myArray.toString();
Hope this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2024 10:51 AM
Hi @Anna_Servicenow ,
Try this code working on my PDI
CODE:-
var myArray = [];
function chkArr(val) {
if((val != "") && (myArray.indexOf(val) == -1)){
myArray.push(val);
}
}
chkArr(current.u_caseid_1 .toString());
chkArr(current.u_caseid_2.toString());
chkArr(current.u_caseid_3.toString());
chkArr(current.u_caseid_4.toString());
chkArr(current.u_caseid_5.toString());
chkArr(current.u_caseid_6.toString());
chkArr( current.u_caseid_7.toString());
chkArr(current.u_caseid_8.toString());
chkArrcurrent.u_caseid_9.toString());
chkArr(current.u_caseid_10.toString());
current.connect_case_ids_2 = myArray.toString();