I have a customer portal where the user creates a request for revoking a user's rights. The user needs to select a user in the field "Pravice za uporabnika" (Rights for the user), id is 10313. This is an asset field that displays all users. After that, the user needs to select an application in the "Aplikacija" (Application) field, also an asset field, id is 10069, and in the final step, they need to select the right in the "Odvzem Pravice" (Revoke Rights) field, also an asset field, id is 10314. By creating this request, the process of revoking the user's rights on the selected application is triggered. Everything needs to be automated.
I started the automation in the following way:
The automation should remove the selected user in the "Pravice za uporabnika" field from the list of users we obtained in point 2, and then return those users back to the value of the object's attribute in the asset.
PS, I don't have Scriptrunner.
Create a var e.g. NewUporabniki with value:
{{NewUporabniki.concat(CurrentUporabniki.substringBefore(User).concat(CurrentUporabniki.substringAfter(User)}}
Hello,
These are screenshots of current state.
First two screenshots will give me the list of users currently assigned to the right from the created ticket. For example CurrentUporabniki: [user 1, user 2, user 3].
Then this part will give me the user whi selected in the "Pravice za uporabnika" field. For example value is user 1.
User 1 has to removed from the list that I've got in CurrentUporabniki var.
The last step is to edit object attribute with User 2, User 3.
Where do I have to put var "NewUporabniki" from your answer?
{{NewUporabniki.concat(CurrentUporabniki.substringBefore(User).concat(CurrentUporabniki.substringAfter(User)}}"
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I assume that you have currently all users listed in the Application object in the attribute 'Username' (Google translate FTW)
You can't remove one user from an attribute, what you can do is to update the attribute with the new list, being the smart value {{NewUporabniki}}.
You need to find the following values:
Then you need to create a send web request action to:
Custom data:
{
"attributes": [{
"objectTypeAttributeId": "{{attributeId}}",
"objectAttributeValues": [
{{NewUporabniki.asJsonObject("value")}}
]
}]
}
Headers:
Content-Type: application/json
Authorization: Basic <API token>
Assuming that 'User 1' is the Jira accountId value and not the displayName/Email address.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I tried to solve this in multiple ways, but I was unsuccessful. Can I describe the issue from the beginning once again?
When a ticket is created, the fields 'Odvzem Pravice' (Users rights) and 'Pravice za uporabnika' (User) are selected. Both fields are asset fields. The field 'Odvzem Pravice' (Users rights) is linked to the object type 'Pravice' (Rights), while the field 'Pravice za uporabnika' (User) is linked to the object type 'Employee' in Assets.
I have changed the variable names to English.
In the last log, I get the data that I need to update the attribute of an object in Assets.
The problem arises with the ', ' which can appear at the beginning, in the middle, or at the end, depending on where the deleted data was located.
I need to send this final data via API to Assets.
Thank you for the help :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Examples of last log:
[TS-140, , TS-139, TS-338]
[TS-140, TS-139, ]
I think that ", " is the main issue.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Rudy Holtkamp here is the solution.
I managed to remove the excess value, and after that, I successfully updated the attribute value of the object in Assets.
It works! :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Nice!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.