Community Tip - When posting, your subject should be specific and summarize your question. Here are some additional tips on asking a great question. X
Hi I am still trying to learn java whilst trying to develop my thingworx app and I am trying to write a service to define the production shifts depending on if a boolean property is true and and shift has been selected from a drop drown (string) but services keeps failing saying specific shift (string) is not defined see image. Do I need to do a function call to return the string?
Solved! Go to Solution.
Hi Bhawna
Please see below
Regards
Carl
I reviewed your code and it seems fine. I also did a quick test and I am able to execute a similar service on my local instance.
Please enable debug logging in script logs and after replicating the issue again provide us the Script and ScriptError logs to check the exact cause.
Regards,
Sachin Sharma
Hi Sachin,
Code is now working seems I did not put the Mornings like this 'Mornings' and I now do not get the error but can you tell me why it always evaluates to the last else statement even if the conditions for the else if are met ?
I used below code and when else if condition is true it is updating thing property prop1 value to 2.
There are two inputs machinerunselect (boolean) and productionshifts (string)
let runselect = machinerunselect;
let shifts = productionshifts;
if(runselect ===true && shifts === "Mornings" ){
(me.prop1 = 1);}
else if(runselect ===true && shifts === "Afternoons" ){
(me.prop1 = 2);}
else(me.prop1 = 5);
For testing purpose remove the time condition from first else if statement and execute the service again, pass the following inputs productionshifts = Nights and machinerunselect = true
Check whether ShiftScheduleUID updated to 3 or not.
Regards,
Sachin Sharma
Hi Sachin,
Thank you it works now but why will it not work with the time variable? If I run the time script on the console it returns a value so why does it evaluate to false in my script on thingworx?
Fixed it now needed
const d = new Date();
let time = d.getHours();