Important Update: Archer Community Scheduled Maintenance on November 23–24 - New Community Launching Soon! Learn More..
2023-07-03 12:30 PM
Hi ,
We have a requirement to populate source data from one application to other application on a button click by creating a record, we have achieved this using content API buy writing to JavaScript code in custom object. When a single value is selected in the source application the value is moving to target as per below code. When multiple values are selected only 1 values is moving to target application (its happening because we used [0] in below code). Can someone help me on how the code looks when more than one value is selected in source.
var countries = $CM.getFieldvalue(1234);
var countries = 0;
if(countries !=null){
countries = countries.toString();
countries = countries.split(";");
countries_value = countries[0];
}
and now using this countries_value to be populated in target by using Type, tag, value and valuelistids attributes.
Thanks
2023-08-18 09:50 AM
@AnuragTyagi & @DavidPetty This one worked for me as below
countries_value = countries.map(item=> item.split(':')[0] );
13870": {
"Type": 4,
"Tag": "Severity (Values List)",
"Value": {
"ValuesListIds": countries_value,
},
"FieldId": 13870
}
2023-07-03 12:35 PM
@Bharath it looks like you're only returning the first value of the split, countries_value = countries[0];. You're going to have to iteratate through the split array and populate accordingly.
The JSON for setting multiple values shoud look like this:
"13870": {
"Type": 4,
"Tag": "Severity (Values List)",
"Value": {
"ValuesListIds": [
63738,
63821
]
},
"FieldId": 13870
}
Advisory Consultant
2023-07-03 01:51 PM
Try something like this:
countries_value = countries.split(";").map((country, index) => {
return(
countries[index] + {index < contries.length - 1 ? ", " : ""}
);
})
Advisory Consultant
2023-07-10 11:11 AM
Hi @DavidPetty ,
Output of source application is ['603:0', '604:0', '605:0'].
I have tried something like this but in target its not populating anything. Am i missing anything?
var countries = $CM.getFieldvalue(1234);
countries_value = countries.map(item=> item.split(':')[0] + ':0');
"13870": {
"Type": 4,
"Tag": "Severity (Values List)",
"Value": {
"ValuesListIds": [
countries_value
]
},
"FieldId": 13870
}
2023-07-11 08:59 AM
You almost there, I think you need this.
var countries = ['603:0', '604:0', '605:0'];
countries_value = countries.map(item=> item.split(':')[0] );
countries_value= ['603', '604', '605'];
2023-07-11 11:29 AM - edited 2023-07-11 11:30 AM
@AnuragTyagi I already tried it. Its not working. Nothing is populating in target app
2023-07-17 02:24 AM
@Bharath You have to include double quotes in every value. your final object should be like this.
"13870": {
"Type": 4,
"Tag": "Severity (Values List)",
"Value": {
"ValuesListIds": [
"63738",
"63821"
]
},
"FieldId": 13870
}
I don't know how you will do but in my case its working with below code.
var idsOfValue= ["\"601\"", "\"602\""];
var Data="{\"Content\":{\"Id\":12345678,\"LevelId\" :0000,\"FieldContents\" : {\"9999\" :{\"Type\" : 4,\"Value\": {\"ValuesListIds\": ["+idsOfValue+"]},\"FieldId\" :9999}}}}";
2023-08-18 09:50 AM
@AnuragTyagi & @DavidPetty This one worked for me as below
countries_value = countries.map(item=> item.split(':')[0] );
13870": {
"Type": 4,
"Tag": "Severity (Values List)",
"Value": {
"ValuesListIds": countries_value,
},
"FieldId": 13870
}