Prevent Deletion of Existing Relationship Records in cmdb_rel_ciWhen Submitting Catalog Multipletime

NikhithaNikki
Tera Contributor

I have a requirement related to a catalog item that includes:

  • A reference field to select a digital platform from a table.
  • A list collector fields (I have 12 fields) that allows users to select multiple values.

When the catalog item is submitted, it creates relationship records in the cmdb_rel_ci table based on the selected values.

Requirement: When the user submits the catalog item again, the list collector should:

  • Populate existing relationship records (if they already exist).(its done)
  • Create new relationship records (if they don’t exist).
  • Avoid deleting any existing relationship records that are not part of the current selection.

Essentially, I need to compare the user-selected values in the list collector with the existing relationship records in cmdb_rel_ci, and:

  • Create new records for values that don’t exist.
  • Skip creation for values that already exist.
  • Do not delete any existing records.

Has anyone implemented a similar logic or can suggest the best approach to achieve this?

Thanks in advance!

NikhithaNikki_0-1755727227007.png

I am trying like this in the flow can you help me. how can we do with flow designer

2 REPLIES 2

Mark Manders
Mega Patron

I assume the relationship record is always the same? Parent is one of the selected fields and child is the other? And the relationship type is the same as well?

If that's the case, you can do a simple lookup to the cmdb_rel_ci table within a 'for each' loop where the 'for each' is the record in your list collector field, where parent is the one, child is the other and the relationship is there. 

If you don't add any 'deletion' steps, you won't delete anything. I am not clear on what you mean with 'update existing relationship records'. If they exist, what is there to update? Or are you selecting other things as well?


Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark

Laveena-Agarwal
Kilo Sage

Hi @NikhithaNikki 

There are no issues using Flow Designer; however, I believe there is a more optimal design to implement this requirement.

Do we really have to submit this catalog item if relationship already exists?
If not, we could inform the user with a pop-up or an information message indicating that the relationship already exists.