- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-09-2023 03:32 AM
Hi All,
I have script include Output as below:
- return ID+ GroupName;
i.e. 12345abcd6789Hardware
Now, I need to use both the outputs i.e., ID and group name in client script.
Here, group name can be anything, so how can I show that in client script?
Requirement: How can I split the output from script include? as I want to use ID in if statement and group name in error message.
Client script:
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-09-2023 04:39 AM
Hi could you please try below;
return (ID+ ":" +GroupName).toString();
function scriptinclude (response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
answer = answer.split(":");
g_form.addInfoMessage(answer[0]);
g_form.addInfoMessage(answer[1]);
if (answer[1] == 'abcd6789' ) {
g_form.addErrorMessage('GroupName already exist with this id'); //Groupname will be groupname obtained from output of script include
} else if (answer[1] == 'tyu1415'){
g_form.addErrorMessage('GroupName already exist with this id'); //Groupname will be groupname obtained from output of script include
}
}
If my answer solved your issue, please mark my answer as ✅Correct & 👍Helpful based on the Impact.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-09-2023 03:45 AM - edited 05-09-2023 04:43 AM
Hi @Rakshanda Kunte ,
Instead of passing values this way, you can pass a JSON object which would contain the ID and group name separately and then you can fetch them in the client script, please refer to the scripts below:
Script include:
var obj = {};
obj.id = ID;
obj.group_name = GroupName;
return JSON.stringify(obj);
Client script:
function scriptinclude (response) {
var a = JSON.parse(response.responseXML.documentElement.getAttribute("answer"));
alert(a.id + ' ' + a.group_name);
if (a.group_name == 'abcd6789' ) {
g_form.addErrorMessage('GroupName already exist with this id'); //Groupname will be groupname obtained from output of script include
} else if (a.group_name == 'tyu1415'){
g_form.addErrorMessage('GroupName already exist with this id'); //Groupname will be groupname obtained from output of script include
}
}
If my answer has helped with your question, please mark it as correct and helpful
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-09-2023 04:30 AM
Thanks for looking into this.
g_form.addInfoMessage(a.ID);
g_form.addInfoMessage(a.group_name);
However, these 2 lines are not giving any output.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-09-2023 04:39 AM
If I only return a in client script,
i.e. g_form.addInfoMessage(a);
Output = {"id":"123456ty56vce6","group_name":"Hardware"}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-09-2023 04:43 AM
@Rakshanda Kunte - if you're using this for testing, you can use alert() insert, I've updated the code, please refer that.
If my answer has helped with your question, please mark it as correct and helpful
Thanks!