It's all about the answers!

Ask a question

How do I find newly added Approvals in a Operation Advisor?


Sudheer Rugbeer (11521632) | asked Jan 18 '16, 1:43 p.m.
Hi

I am developing a server-side operation advisor extension, which needs to allow a specific role from creating specific Approvals (based on the approval name). This approval can be added at any point in the Work Item workflow.

How can I find out what are the newly created approval descriptors during a work item save?

Thank you,
Sudheer

One answer



permanent link
Ralph Schoon (63.1k33646) | answered Jan 18 '16, 2:13 p.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
How about

  1. Getting the old state of the work item
  2. Getting the new state of the work item
  3. Getting the approvals from the old state
  4. Getting the approvals from the new state
  5. Figuring if there is a new one by comparing the number of attachments and finding the one that is not in the old list (maybe there is a date on the approval, not sure)

Comments
Sudheer Rugbeer commented Jan 18 '16, 3:19 p.m.

Hi Ralph


This is the approach I am following, however there is a scenario where an approval can be added and another deleted in the same save operation, which would mean that the old number of approvals is the same as the new number. However, I can work around this by creating another extension which prevents deletion of approvals.

I was hoping that there would be a more reliable to determine what approvals where added, removed, or changed as part of the save operation.

Thanks,
Sudheer


Geoffrey Clemm commented Jan 18 '16, 7:27 p.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

Just modify step 5 to say "Compare the entries on the old list of approvals with the entries on the new list of approvals.   If there are any differences, fail the save request."


Ralph Schoon commented Jan 19 '16, 2:00 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

Also have a look at the UUID's of the approvals. These are unique and would allow you to determine any changes if you iterate both lists.


Sudheer Rugbeer commented Jan 24 '16, 12:26 a.m.

How do I get the UUID's of the approvals?
I don't see any applicable methods in the IApprovalDescriptor interface.


Ralph Schoon commented Jan 25 '16, 11:25 a.m. | edited Jan 25 '16, 11:26 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

Interesting, usually everything has a UUID, but I couldn't find anything for approvals at a glance. You could try to debug if you can see anything that you could use to compare. Otherwise you have to resort to a text compare, which is not very precise.


sam detweiler commented Jan 25 '16, 2:35 p.m.

You could use the hashCode() method, which should return a unique value

showing 5 of 6 show 1 more comments

Your answer


Register or to post your answer.


Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.