Skip to main content
Question

ExecuteScript function in FSM Mobile button as Control Event

  • September 14, 2023
  • 4 replies
  • 70 views

Forum|alt.badge.img+7

Hi Experts!

 

I am trying to run a SQL Update Statement via Client Script in FSM Mobile.

 

I am adding a Client Script to a Control Event. This Client script will run the SQL Client Script via ‘ExecuteScript’ function.


Client Script Code:
var parentTaskId = getCurrentKeys("task","task_id");
var bookingRequestId = getDBValue(stringFormat("SELECT user_def24 from task where task_id ='{0}'",parentTaskId));
var custSig = getDBValue(stringFormat("SELECT user_def_num1 from task where task_id = '{0}'",parentTaskId));    
var custSigName = getDBValue(stringFormat("SELECT user_def5 from task where task_id ='{0}'",parentTaskId));
var custNRIC = getDBValue(stringFormat("SELECT user_def4 from task where task_id ='{0}'",parentTaskId));


executeScript("C_BOOKING_CS_VALD_NEXT_SQL",[custNRIC,custSigName,bookingRequestId]);

 

 

SQL Client Script Code:
UPDATE task
SET user_def4 = '{0}', user_def5 ='{1}'
WHERE user_def24 ='{2}'

 

Currently I am getting an error when i run the script in mobile, the Executescript line contains wrong syntax. 

How do I add the pulled values for the SQL client script to pull?

 

4 replies

Shneor Cheshin
Superhero (Employee)
Forum|alt.badge.img+28
  • Superhero (Employee)
  • 1138 replies
  • September 15, 2023

Hi @StejonatL 

I don’t think that executing a client script SQL is supported by executeScript.

You can try running the query directly in your script with setDBValue

Or even better use generateDataTransaction & saveDataTransaction to update 

If you need to update multiple records, you might want to consider a loop or using a business rule.

 


​​​​​

 

Cheers!

 

Forum|alt.badge.img+7
  • Author
  • Do Gooder (Customer)
  • 47 replies
  • September 15, 2023

Hi @Shneor Cheshin,

 

Thanks for your response.

 

When set Variables for setDBValue function as below

 

setDBValue(stringFormat("UPDATE task set user_def4 ='{0}' where user_def24 ='{1}'",custNRIC,bookingRequestId));

 

I need to click save twice in mobile app for all values to be updated, why is that? i am updating multiple values. When I Click save once, the main value is updated. When i click save again, the rest of the values are updated.


Forum|alt.badge.img+7
  • Author
  • Do Gooder (Customer)
  • 47 replies
  • September 15, 2023

For AddToTransaction, is it possible to add where conditions?


Shneor Cheshin
Superhero (Employee)
Forum|alt.badge.img+28
  • Superhero (Employee)
  • 1138 replies
  • September 15, 2023

@StejonatL

You will need to debug your code. Not sure why you need to trigger it twice.

Can you share the latest code you have? And configurations?

What do you mean by clicking ‘Save’? How did you configure your button?

I am not familiar with any conditions used with addToDataTransaction. What conditions do you wish to apply?

Cheers!

 


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings