cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

Getting random error using substring to extract a string

Hi,

 

I'm tyring to use substring to extract a the first 5 characters of a string variable, which I then plan to put in a second variable. My code mostly works, but every few tries it fails with the following message:

 

error.png

 

 

 

 

 

I've tried this by entering my substring text into the set variable value field, and by using Compose and using the substring in the Compose 2 Inputs field. in both cases it works sometimes, about 3 out of 5 time. and fails the rest of the time with the message above.

 

Here's what my variable and compose sections look like:

substrin.png

 

Can anyone point out what I am doing that is making it unstable? 

 

Thanks much!

 

2 ACCEPTED SOLUTIONS

Accepted Solutions
Anonymous
Not applicable

I got it sorted. I decided to try grabbing the department info from Office 365, rather than SharePoint. Now I have my initiator "When an item is created", I feed the Person Email I obtained from that (the URI) into the Office 365 Get User Profile (v2), then grab the Department from there. 

 

making it work.png

 

Thank you so much for all the assistance!

View solution in original post

I find there is a timing problem with the trigger that makes created information unreliable.  I ususally use the modified information since it will be the same as created when a record is created.  Modified and Modified by seem to be more reliable.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

View solution in original post

6 REPLIES 6
Pstork1
Dual Super User
Dual Super User

Are you accounting for the fact that people may not have a department list in their profile?  If the string is less than 5 characters or null this is exactly the kind of message your will get.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.
Anonymous
Not applicable

Hi  

 

Have you looked at a run that errored out to see what is in Vartrim? If you expand the actions in the run you can see inputs and outputs. That might help figure out why they are causing an error.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.
Anonymous
Not applicable

Thank you for the pointer of where to look. I hadn't looked at the flow above the error.

 

How interesting! I ran the flow for the same person mutliple times. When I get the error, the "Person" field in the initiating "When an item is created" section is coming back with the Department and JobTitle = null. When I rerun it for the same name and it works, the Department and JobTitle contain values.

 

Working:

"Department": "12345 - Operations",
"JobTitle": "IT Manager"
}
 
Not Working:
"Department": null,
"JobTitle": null
}
 
So, yes, the following varTrim has no data to work from.
 
So, two questions.
  1. Why would it come back null some times? Is there some way to fix it? Since it's random, it seems like it may be a timeout issue, but that's me guessing.
  2. Is there something I can do to re-request the data if 'null' is returned? Or a way to gracefully handle null as a value?
Anonymous
Not applicable

I got it sorted. I decided to try grabbing the department info from Office 365, rather than SharePoint. Now I have my initiator "When an item is created", I feed the Person Email I obtained from that (the URI) into the Office 365 Get User Profile (v2), then grab the Department from there. 

 

making it work.png

 

Thank you so much for all the assistance!

I find there is a timing problem with the trigger that makes created information unreliable.  I ususally use the modified information since it will be the same as created when a record is created.  Modified and Modified by seem to be more reliable.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Helpful resources

Announcements
Power Automate News & Announcements

Power Automate News & Announcements

Keep up to date with current events and community announcements in the Power Automate community.

Community Calls Conversations

Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Automate Community Blog

Power Automate Community Blog

Check out the latest Community Blog from the community!

Users online (6,708)