Create an issue only if an insight object does not exist

Anna Protopapa July 13, 2021

We need a condition to validate if an object is already created in an object schema and do not permit to create an issue with this object value in a specific field.

Thank you

1 answer

0 votes
David Sumlin July 13, 2021

I'm not 100% sure I understand your use case, but it sounds like you have:

  1. An Insight schema with objects
  2. An Insight custom field

You asked

a condition to validate if an object is already created in an object schema and do not permit to create an issue with this object in a specific field

First things first. 

  1. If you're trying to validate an issue upon creation, it would be a validator, not a condition
  2. If you have an Insight custom field on an issue create screen and you DON'T want the user to select an object which exists in a schema (I'll assume we're talking about the object as a reference attribute, since the field would always show no objects for selection...since ...they'd exist otherwise)

It sounds like what you might want is to alter the "Filter scope (IQL)" section in the field configuration to apply your logic. That way, the field will only show the objects which satisfy your logic.

Anna Protopapa July 13, 2021

For the 2nd bullet: I dont want an insight field. I want a text or integer field to fill and if this value does not exist as an object in insight then an issue and an object will be created.

I suppose I will use the insight post function but I will need help with the IQL condition

Thank you

David Sumlin July 13, 2021

So, it sounds like you're using an issue as the template to create an object.

You have a couple of options.

1. You can put all of your logic in the create workflow validator to determine if an object exists which matches the text or integer field. If the object already exists, throw an error message to the user and not let the issue be created. If the object doesn't exist, then create the object and let the issue creation succeed.

2. Let the issue get created, and then have either a post-function that performs the above work and then transitions the issue to a completed status with a resolution of "object created" or "denied" or something like that.

Like Anna Protopapa likes this
Anna Protopapa July 13, 2021

If I select the first option I suppose I will create a Validator on the Create transition. I will select Insight Validators --> Run a groovy script within this validator. 

Can you help me with the groovy code I will use?

David Sumlin July 14, 2021

I think you're correct. 

I don't unfortunately have a collection of Insight Groovy scripts yet. I would suggest starting to look at the examples originally provided by Mindville

Suggest an answer

Log in or Sign up to answer