Missed Team ’24? Catch up on announcements here.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Remove single attribute value from Insight Object using automation

maurício heberle September 26, 2022

Scenario:

 

We have an Employees Insight object with an attribute called System Name that stores all applications an user has access.

Using Jira Automation, I can update via webhook to add more applications, but when I try to edit the object to remove, it overwrites the whole attribute. 

 

I want a way to remove a single value from the attributes. Does anyone know if that is possible?

 

2 answers

1 accepted

1 vote
Answer accepted
Stefan Salzl
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 27, 2022

Hi @maurício heberle ,

could you show your automation rule/your api call?

Best
Stefan

Stefan Salzl
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 28, 2022

Hi @maurício heberle ,

did you also add the log action from point 4 in the docu:

Add a log action within the branch to make sure we get the desired results:

List of application: {{object."Application access".Key.asJsonObject("value")}},{{"Application List".Key.asJsonObject("value")}} object to be edited: {{object.id}}

 

Is there any information in your audit log? Could you show the result of your audit log? That might help the community to get further insight into the problem and try to find a solution.

Best
Stefan

Vannam Ganga Yaswanth January 24, 2023

Hi @Stefan Salzl 

how can we remove a single value in a object attribute
instead of adding new values

Example: using automation we can clear all the values in the attribute
But now in my case i need to remove a single value (PF347890)

Is there any wayScreenshot 2023-01-24 195655.png

Mauricio Heberle
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 24, 2023

I forgot to answer this. I think theres no native solution at the moment, because theres no api endpoint for it. 

I believe the best way would be using scriptrunner 

Vannam Ganga Yaswanth January 27, 2023

Can you please add script links

Mauricio Heberle
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 27, 2023
Stefan Salzl
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 30, 2023

Hi @Vannam Ganga Yaswanth ,

as @Mauricio Heberle already mentioned there is no native endpoint solve this. I also tried several ways to solve (with smartValues, iteration and condition) but it´s really tricky.

Could you describe your use in more details? When should an attribute be deleted? where does the information come from which attribute should be deleted? 

Did you check the scripted solution from the link above? 

Best
Stefan

Benavides_ Fernando March 15, 2023

Hi @maurício heberle ,

Probably you already solve this, but I found a way to remove an attribute with native functionality.  To explain it better I'm going to use this example. You have 2 object types: the first is a group object type and the second is a Users object type. The User has an attribute called Group(s) where you associate the user to all the groups is part of. In the example we will be removing one group from the user. The steps in the automation will be the following:

  1. Create a variable with the key group you want to remove.  The variable name I used is "keygroup"
  2. Search for the user object with the lookup object function.
  3. Create a variable with the group attribute in the user. The smart value should look like this {{lookupObjects.Group(s).key}}. The variable name I used was "listgroups"
  4. Use Put object api in web request to update the list of groups in the user. The body should be like this
    {
    "attributes": [
    {
    "objectTypeAttributeId": "70",
    "objectAttributeValues": [
    {{listgroups.remove(keygroup).match("(US-\d\d*)").asJsonObject("value").replace(", ","\"}, {\"value\": \"")}}
    ]
    }
    ]
    }
    Where the objectTypeAttributeId 70 is the group id reference in the User object. Replace the US with the asset key from your instance. 

I hope this helps.

Like # people like this
Vannam Ganga Yaswanth March 16, 2023

Hi @Benavides_ Fernando 

Thanks for the automation

For my use case 
there are two object types
A- Employee details
B - Device details

If you find the below picture 

1. An Object "7741" in A object type has attribute Emp_Hardware with two appended values pushed via automation

2. And B object type has an attribute called Quantity (if the device is assigned quantity will be set to 0, and 1 for unassigned)

- Now i have created a request type in portal named unassign a device,

When reporter creates a ticket he selects the object in first field Employee details (pulls all objects in A object type) as 7741

- In the second insight field he selects the device details objects as PF347890

its backend configuration with IQL 
     Field Name: E_Assigned_Device
     Filter scope (AQL): objecttype="Device Details"
     Filter issue scope (AQL): "Assigned To"=${customfield_XXXX} (XXXX is above field)

**The value PF347890 selected in the field should be removed from the Emp_Hardware attribute
When ticket is moved to closed status**


Screenshot 2023-01-24 195655.png

Benavides_ Fernando March 16, 2023

Hi @Vannam Ganga Yaswanth 

In this case you could skip the 2 step. The steps could be like this:

  1. Create the variable with the E_Assigned_Device key (variable deviceRemoved). Something like {{issue.E_Assigned_Device.key}} just make sure that variable get the key. Ex in the 7741 record the key is AM-132
  2. Create the variable with the list of hardware (variable hardwareList). It should be something like {{issue.Employee details.Emp_Hardware}} I assume that will give you the array of PF347890 and LPTYU678 like this [AM-44, AM-41]
  3. The body for the api update 
    {
    "attributes": [
    {
    "objectTypeAttributeId": "XX",
    "objectAttributeValues": [
    {{hardwareList.remove(deviceRemoved).match("(AM-\d\d*)").asJsonObject("value").replace(", ","\"}, {\"value\": \"")}}
    ]
    }
    ]
    }

    The objecttypeAtributeId must be get it from the 7741 object type.
    I'm assuming the hardware is using a AM key, if that's not the case update the AM in the body.

Like maurício heberle likes this
maurício heberle March 17, 2023

@Benavides_ Fernando It worked!!!! Thank you!!!
I did try using remove with JSON, but my scripting skills werent enough to solve it. 

How'd you find that out?

Anyway, I was freaking out about this back then and now I can proceed with it.

Like # people like this
0 votes
Vannam Ganga Yaswanth March 21, 2023

Hi @Benavides_ Fernando 

I have tried the automation but it doesn't works 

  •  AM-131 value for first variable -
    name [newlist],
    smart value [{{issue.E_Assigned_Device.key}}].

  • {AM-131,AM-252} value for second variable -
    name[hardwarelist],
    smart value [{{issue.E_Employee Details.Emp_Hardware}}]

    It says web request sent successful but both the values are being removed (AM-131,AM-252)

    Audit log.pngAutomation error.png
Mauricio Heberle
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 21, 2023

Show us your whole automation, the API call and the issue which you are trying to modify, please

Vannam Ganga Yaswanth March 21, 2023

Thanks!

Mauricio Heberle
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 21, 2023

Try removing the "For current issue" branch. I am using only the AQL on Branch

Vannam Ganga Yaswanth March 21, 2023

Hi @maurício heberle 

At image 4 its branch AQL where the web request actions works

Mauricio Heberle
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 21, 2023

What I meant is that you dont need another branch like the current issue. This is my automation

Captura de Tela 2023-03-21 às 15.18.40.png

Vannam Ganga Yaswanth March 22, 2023

Hi @maurício heberle  & @Benavides_ Fernando 

It works for me finally.

Thanks so much!

Like # people like this

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
PERMISSIONS LEVEL
Site Admin
TAGS
AUG Leaders

Atlassian Community Events