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

Not able to use String function with Smart Value in lookup object

Sarika Dalal
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 27, 2021

Hi Team,

I got one requirement from customer for insight object, they have one Object Schema In that they are creating object they want once any object got created field AssetID value should be automatically increment by one in the last Object AssetID

Let's take one example here

Object Key    AssetID  

LAB-123        ABC001

LAB-124        ABC002

LAB-125        ABC003

So the field AssetID value should be automatically added, so I am using Automation in JSM

Here is the details about the configuration :

When: Object Created

Then :  Lookup objects

insight query language is  

objectType = TEST ORDER BY AssetIDD DESC

here AssetIDD is text field

Then : edit Object

Select field : AssetIDD

Value : {{lookupObjects.get(1).temp_Asset_ID.charAt(2)}}

ERROR:

Edit Insight field attributes

 

Error updating Object(s)
Objects were skipped
LAB-6858 (temp_Asset_ID = '')

So this is the configuration I have  added but I can see all the text function is not working here and getting always empty value and in Automation audit log I can see error, I can achieve same requirement If I am using only number field but with text field no smart value function is working

following this document : smart-values-text-fields 

Any suggestion why my text function are not working ?

 

Thanks,

Sarika Dalal

2 answers

0 votes
Ignacio Pulgar
Contributor
January 13, 2022
0 votes
Bill Sheboy
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.
October 28, 2021

Hi @Sarika Dalal 

First thing, I do not have Jira Service Desk, so I will try to help based on what I see in your automation rule.

  • Is temp_Asset_ID a defined field in that lookup, as it may not be present if it is returning as empty?
  • For {{lookupObjects.get(1)... I believe this is trying to return the second item in the list, as these are 0-base indexed.  Is that what you want?  Otherwise if you want the first one, perhaps try: {{lookupObjects.first...
  • Your AssetID values are of the format ABC001, and you are trying to access at charAt(2).  According to the documentation, this one is 1-base indexed, so this may not be what you want.  Consider writing the values to the audit log to confirm what is happening.
  • And, as your AssetID values are alphanumeric, if you are trying to increment with a rule, wouldn't you need to split that value into the alpha and numeric parts, increment, and then concatenate the result?

Kind regards,
Bill

Sarika Dalal
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
November 1, 2021

Thank you for the response @Bill Sheboy .

let me add few more points here :-

when I am trying {{lookupObjects.get(1).temp_Asset_ID}} its giving me value of the field after that I am using function {{lookupObjects.get(1).temp_Asset_ID.charAt(2)}} that is not working. with charAt function I am just testing String functions.

Issue is all string functions is not working here and every time I am getting null response.

Your thought is correct about point 4 I am going to split number and text field value only and then I will do increment in number.

 

Regards,

Sarika Dalal

Bill Sheboy
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.
November 1, 2021

You are using Cloud, correct?  If so, perhaps do this in two steps to force the type conversion to string:

  • create a variable and set the value to the temp_Asset_ID
  • then perform the charAt() on the variable

I recall needing to do this for other fields which are dynamically generated before I could use them in expressions.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events