Community Tip - Have a PTC product question you need answered fast? Chances are someone has asked it before. Learn about the community search. X
I have a service retrieving a json file from several devices via the contentloaderfunction getjson. After the json is retrieved I parse the data and output an infotable and display the values in a mashup. If the service fails the widgets displaying the data show errors on my mashup. I would prefer to show no data vs an errored widget. Is there anyway to have the service return an empty infotable?
Solved! Go to Solution.
Place the script of your service in a try catch and have an empty table equal to the result of your script if it goes into the catch. for example:
try {
//insert current script here
result = PopulatedInfotable
}
catch(err) {
result = emptyInfoTable
}}
Hope that helps
Hello,
I can see 2 possible solutions to not store errors in the infotable.
The first that comes to my mind is a workaround, you could do a regular expression match on the values after they have been fetched. The regular expression should match a common term in the error messages, like "error" or "warning". If the expression matches you don't store it in the infotable.
The second would be to check for possible errors while receiving, in case of error, to not use the variable for Infotable input. I haven't tested this however.
Regards,
Pascal
Place the script of your service in a try catch and have an empty table equal to the result of your script if it goes into the catch. for example:
try {
//insert current script here
result = PopulatedInfotable
}
catch(err) {
result = emptyInfoTable
}}
Hope that helps