Page 1 of 1

Valid workitem check

Posted: Tue Sep 10, 2019 6:33 pm
by CoJeff
I'm trying to use a saveworkitem script that will set a custom field based on a status. All of that is working except when a workitem ID is used that doesn't exist. If the script encounters a invalid workitem ID it exits and polarion gets an error log entry. I'm not very good at APIs and I've tried trackerService.findWorkItem(projectId, item) but the script still exits.

What would be a good way to verify that an ID exists before I try to do anything with it?

Thanks for any help.

~jeff

Re: Valid workitem check

Posted: Tue Sep 10, 2019 8:31 pm
by CoJeff
I did finally try a try-catch block that seemed to do the trick. I still would like to know if there is a way to check if an ID is valid.

Re: Valid workitem check

Posted: Mon Sep 16, 2019 10:01 am
by J├╝rgen
The class IObject has a method "isUnresolvable()" that can be used for a work item as well.

Re: Valid workitem check

Posted: Thu Sep 19, 2019 6:02 am
by rushirathi
Thanks for the information.