The Zurich release has arrived! Interested in new features and functionalities? Click here for more

Index of Not working

sushma9
Tera Contributor

Hi All,

I am using Index of  with string and its not working. Please find the sample script below. when i tested i am only getting the If validation and else if is not working. please let  me know if any changes has to done.

Note : filed name is same for all the conditions.

script :

 if (field name.indexOf("x")<1){

here i am triggering one event 

} else if (filed name.indexOf("y")<1 || filed name.indexOf("z")<1){

here i am triggering another event 

} else if ( filed name.indexOff("x")<1 && filed name.indexOf("y")<1 || filed name.indexOf("z")<1){

here i am triggering another event  ;

}else{

here i am triggering another event  ;

}

14 REPLIES 14

@Anurag Tripathi 

its not working

 

Can you show what you are trying?

-Anurag

@Anurag Tripathi 

1. filed type is reference and i have used the below code but its not working .

if ( filed_name.getDisplayValue().indexOf("x)<1) {

triiger the event

}else if (filed_name.getDisplayValue().indexOf("y")<1 ||filed_name.getDisplayValue().indexOf("z")<1 ){

triiger the event

}else if (filed_name.getDisplayValue().indexOff("x")<1 && filed_name.getDisplayValue().indexOf("y")<1 ||  filed_name.getDisplayValue().indexOf("z")<1 ){

triiger the event

} else {

triiger the event

I just asked you move to <0 instead of using <1

also  hope you are using current.field_name.getDisplayValue()

 

You just send the script from your question, where is the code that I suggested you use, there wre changes I made, comment i added. did you see/use that?

-Anurag

@Anurag Tripathi 

Please find the script .

Script :

var gr= new GlideRecord("table");
        gr.addQuery('u_request_item ', current.parent);
        gr.query();
        if (gr.next()) {
            if (gr.filed_name.getDisplayValue().indexOf('x')< 1) {
                gs.eventQueue("test.Notification", current, "", "");
                
            } else if (gr.filed_name..getDisplayValue().indexOf('y') < 1|| gr.filed_name..getDisplayValue().indexOf('z')< 1) {
                gs.eventQueue("test1.Notification", current, "", "");
                
            } else if (gr.filed_name..getDisplayValue().indexOff('x) < 1 && gr.filed_name..getDisplayValue().indexOf('y') < 1|| gr.filed_name..getDisplayValue().indexOf('z') < 1) {
                gs.eventQueue("test2.Notification", current, "", "");
                
            } else {
                gs.eventQueue("test3.Other.Notification", current, "", "");
                
            }