248 Posts
Giuse
6 years ago
4
Topic

Hi, how to setup a triggering condition in conditional states based on a substring? Like I want to trigger an action when the value of a field contains the string XXX? I tried to put % around XXX as in the LIKE statement but it is not supported. 

Do we need to use "call function" option and define a custom JS function that searches for the substring? If so, to trigger the action the custom function has to return true?

thanks

Giuse

Get a VIP membership
4229 Posts
Kadministrator
6 years ago
1
Level 1

You will probably need to use function, from what I see in the code it need to return 1 on success on 0 on failure.

248 Posts
Giuse
6 years ago
0
Level 2

Ok, but... when will this function be called..? I don't understand how the trigger is activated when using "call function" condition...

thanks

5 years ago
0
Level 1

Hi

Never used this feature but I don't know how the JS function should be written to work here.

Klas, please, can you give us an example ?

thanks

cyril

5 years ago
0
Level 1

Hi

Without any answer we just give here our simple solution:

  1. put a conditional state on your field , select the 'function' method and write down the name of the JS function (here triggering_function )
  2. create a JS code field (in RAW mode) in the view or just write the JS code in the template
  3. the JS code should look like : in this example art_alias is the triggering field  

function triggering_function ()

var value = document.querySelector('#art_alias').value; 

if value == "This is the end"

return 1; 

else 

return 0;

}


of course for this purpose we don't need a JS call but it gives you a simple example


Thanks


cyril



Get a Book for SEBLOD