Hi there,
I am putting an automation in place that if the approver name is deleted from the field automation writes it back.
I am capturing the previous value of the approvers field using this
{{fieldChange.from}}
The result gets stored in a variable.
The problem is the ID that is being stored is an object so it has [ ] around it.
I saw there is a .remove that can be used to remove a string from a field but not sure how to apply it to this automation.
I had this
{{PreviousValue.remove("[")}} just to see if it would be removed as a log event but it spits out an error stating invalid JSON.
Maybe I am going about this incorrectly so would love to understand how this should be put together.
The ultimate goal is to edit the issue and update the approver field with the stored variable.
Hi @Ste404 and welcome to the community!
In this type of case, I typically capture the JSON as is in the variable and then create a second variable that performs the cleanup of the first variable then use the second variable in my subsequent conditions/actions.
hey @Mark Segall thanks for that, you answer means I was on the right track but I wasn't sure where to put the multiple lines in order to trim the previous variable.
I assumed I need these two lines
{{PreviousValue.remove("[")}}
{{PreviousValue.remove("]")}}
but in the 'Smart Value' line in create variable it gets entered as a single line.
I put those two items in side by side but it failed, do I need to wrap them in another set of brackets?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
{{YOURVARIABLE.match("\[(.*?)\]")}}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
ok that fixed the parsing, great info.
This is failing now, but will have a scratch around to see what I have mistyped.
{
"fields": {
"approvers" : [{ "id": "{{FixedPrevious}}" } ]
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I was over complicating the last part, I just used the smart value directly to edit the Approvers field.. works a charm.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.