Skip to main content

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?

 

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!

 

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.


For AddToTransaction, is it possible to add where conditions?


@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