[{"id":"864edeac.95206","type":"function","z":"ba8ee349.48534","name":"Create New Work Order.","func":"// Generic parameters...\nmaximoIP = \"\";\nmaximoUser = \"\";\nmaximoPassword = \"\";\nmaximoSite = \"BEDFORD\";\nmaximoDescription = \"Low Fuel Oil Request from \" + msg.payload.d.location;\n\n// Save for nodes further down the process.\nmsg.maximoIP = maximoIP\nmsg.maximoUser = maximoUser\nmsg.maximoPassword = maximoPassword\n\n// Construct URL to create new Work Order. Specify format to be JSON when the new Work Order is returned.\nmsg.url=\"http://\" + maximoIP + \"/maxrest/rest/mbo/workorder?_lid=\" + maximoUser + \"&_lpwd=\" + maximoPassword +\n\"&_compact=true&_format=json&description=\" + maximoDescription + \"&siteid=\" + maximoSite + \"&location=\" + msg.payload.d.location;\n// To create new record, use the PUT method.\nmsg.method=\"PUT\";\n\nreturn msg;","outputs":1,"noerr":0,"x":475.99998474121094,"y":144,"wires":[["c31ed499.dabb18","2f1672f2.34145e"]]},{"id":"c31ed499.dabb18","type":"http request","z":"ba8ee349.48534","name":"REST Create WO","method":"use","ret":"txt","url":"","tls":"","x":677.9999847412109,"y":188,"wires":[["7ad6486c.f858f8","1e7005bc.f0532a"]]},{"id":"d88ed3fb.2bd87","type":"function","z":"ba8ee349.48534","name":"Change status.","func":"// The new Work order is returned after it has been created so we can grab the ID from there.\nworkorderid = msg.payload.WORKORDER.WORKORDERID\n\n// We want to change the status to apporved and also add a memo.\nmaximoStatus = \"APPR\";\nmaximoMemo = \"Status change from the Maximo REST API\";\n\n//Get saved parameters.\nmaximoIP = msg.maximoIP;\nmaximoUser = msg.maximoUser;\nmaximoPassword = msg.maximoPassword;\n\n// Construct the URL, this time we need to use the ID returned for the Workorder.\n// We also specify the new status and memo, along with the &~wo=this parameter which tells us to change this specific Workorder.\n// Since the staus and memo parameters belong to a web service they have a tilde prefix.\nmsg.url=\"http://\" + maximoIP + \"/maxrest/rest/mbo/workorder/\" + workorderid + \"?_lid=\" + maximoUser + \"&_lpwd=\" + maximoPassword +\n\"&_compact=true&_format=json&~status=\" + maximoStatus + \"&~memo=\" + maximoMemo + \"&~wo=this\";\n// Use the POST method to update the Workorder.\nmsg.method=\"POST\";\n// Since we want to invoke a WebMethod, we need to set a header with the specific method we want to invoke, in this case changeStatus.\nmsg.headers = { \"x-http-method-override\" : \"changeStatus\" };\nreturn msg;","outputs":1,"noerr":0,"x":1033.999984741211,"y":272,"wires":[["eacfc178.ccc77"]]},{"id":"7ad6486c.f858f8","type":"json","z":"ba8ee349.48534","name":"Convert to JSON","x":861.9999847412109,"y":229,"wires":[["d88ed3fb.2bd87"]]},{"id":"eacfc178.ccc77","type":"http request","z":"ba8ee349.48534","name":"REST Change Status","method":"use","ret":"txt","url":"","tls":"","x":1224.0000457763672,"y":318,"wires":[[]]},{"id":"bc070092.6431b","type":"ibmiot in","z":"ba8ee349.48534","authentication":"boundService","apiKey":"","inputType":"evt","deviceId":"test2","applicationId":"","deviceType":"+","eventType":"+","commandType":"","format":"json","name":"IBM IoT","service":"registered","allDevices":true,"allApplications":"","allDeviceTypes":true,"allEvents":true,"allCommands":"","allFormats":"","qos":0,"x":66,"y":69,"wires":[["b894bfba.02024","88721da3.e6de7"]]},{"id":"88721da3.e6de7","type":"function","z":"ba8ee349.48534","name":"Filter for Low oil requests","func":"if (msg.payload.d.level > 600 || msg.payload.d.prevval < 600) {\nreturn msg; \n} else if (msg.payload.d.level < 600) {\n return false;\n} else {\n return false;\n}","outputs":1,"noerr":0,"x":235,"y":117,"wires":[["864edeac.95206","68c44852.6d1168"]]},{"id":"1e7005bc.f0532a","type":"debug","z":"ba8ee349.48534","name":"","active":false,"console":"false","complete":"false","x":865.9999847412109,"y":148,"wires":[]},{"id":"68c44852.6d1168","type":"twilio out","z":"ba8ee349.48534","service":"_ext_","twilio":"49875d18.995c94","from":"","number":"0123456789","name":"Text To User","x":436.99998474121094,"y":66,"wires":[]},{"id":"b894bfba.02024","type":"debug","z":"ba8ee349.48534","name":"","active":true,"console":"false","complete":"payload","x":225.99998474121094,"y":42,"wires":[]},{"id":"2f1672f2.34145e","type":"debug","z":"ba8ee349.48534","name":"","active":true,"console":"false","complete":"url","x":674.9545135498047,"y":100.82670593261719,"wires":[]},{"id":"49875d18.995c94","type":"twilio-api","z":"","sid":"","from":"","name":"Twilio"}]