- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-30-2017 03:18 PM
Hi All,
I have having trouble scripting a condition that will check if my value contains a certain value.
This is on incident and the field to check is reference Company name field from core_company table.
I have retrieved the value using Ajax call and now I want to check if it contains a value like Dutch Re
if(g_form.getValue('gr.name') ????? 'Dutch Re')
I have read upon using indexOf but may attempts trying to use it failed. Idea is if IndexOf finds < -1 it should indicate the value is there
and then I want to show or hide section tabs.
If anyone can advise or have another suggestion that be greart.
Thanks
Ellie
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-30-2017 04:27 PM
and correct the condition to --- if(g_form.getValue('gr. name').indexOf('Dutch Re') > -1)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-30-2017 03:30 PM
try using variablename.indexof('Dutch re') > -1 or variablename.indexof('Dutch re') >= 0
to hide or show section g_form.setSectiondisplay('name of the section',true or false);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-30-2017 04:13 PM
Hi Sujala,
Thanks for replying but how would I have to construct the if statement?
I have tried if(g_form.getValue('gr. name').IndexOf (('Dutch Re') >-1
but that didn't do anything.
Many Thanks,
Ellie
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-30-2017 04:25 PM
its the syntax .. i should be small case. its -- indexOf() function.
and does gr.name variable exist on the form or its a result of any table query
try displaying the value of gr.name and see if it is empty or its Dutch re

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-30-2017 03:43 PM
indexOx function is available only for array type not to string
try using split function like below
var arr = str.split('Dutch re');
if(arr.length >1)