Pass the script include output in client script

Rakshanda Kunte
Tera Contributor

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:

 

function scriptinclude (response) {
        var a = response.responseXML.documentElement.getAttribute("answer");
        g_form.addInfoMessage(a);                                        // [12345abcd6789Hardware] - this is output here
        if (a == '12345abcd6789' ) {
            g_form.addErrorMessage('GroupName already exist with this id');            //Groupname will be groupname obtained from output of script include 
        }
        else if (a == '10111213tyu1415')
{
g_form.addErrorMessage('GroupName already exist with this id');        //Groupname will be groupname obtained from output of script include 
        }

 

1 ACCEPTED SOLUTION

Prince Arora
Tera Sage
Tera Sage

@Rakshanda Kunte 

 

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.

View solution in original post

8 REPLIES 8

Hi @Karan Chhabra6 ,

Thank you for your help..!!

@Rakshanda Kunte  - if the solution worked for you, please mark it as correct and helpful

Thanks!

@Rakshanda Kunte ,

 

Solution provided by @Karan Chhabra6  is also correct 🙂 , you missed to parse the data though he has mentioned in his script 

var a = JSON.parse(response.responseXML.documentElement.getAttribute("answer")); 

 

 

Prince Arora
Tera Sage
Tera Sage

@Rakshanda Kunte 

 

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.