cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Learn all about PTC Community Badges. Engage with PTC and see how many you can earn! X

How to create a else statement if Key Does not exist

mpartridge
5-Regular Member

How to create a else statement if Key Does not exist

Hello,

I created a service that uses GetDataTableEntryByKey to search an infotable, and then depending on another field definition it would create a result true or false. However if the key doesn't exist yet it creates an error saying Key Does Not Exist. What ELSE statement would I use so if the Key is not yet created it would populate a false result? Because if it doesn't exist I want it to be result = false.

Does anybody know the right approach for this?

ACCEPTED SOLUTION

Accepted Solutions
mpartridge
5-Regular Member
(To:mpartridge)

I was able to get it to work after changing it from GetDataTableEntryByKey to FindDataTableEntries. Below is the script that I used to get it to work, using the GetDataTableEntryByKey service did not allow the typeof command to work, but it did with FindDataTableEntries.

View solution in original post

2 REPLIES 2

check your variable infotable if equals to null before accessing the property checked_Out

mpartridge
5-Regular Member
(To:mpartridge)

I was able to get it to work after changing it from GetDataTableEntryByKey to FindDataTableEntries. Below is the script that I used to get it to work, using the GetDataTableEntryByKey service did not allow the typeof command to work, but it did with FindDataTableEntries.

Announcements


Top Tags