cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Frequent Visitor

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
Highlighted
Frequent Visitor

Re: Getting random error using substring to extract a string

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

Dual Super User II
Dual Super User II

Re: Getting random error using substring to extract a string

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
Highlighted
Dual Super User II
Dual Super User II

Re: Getting random error using substring to extract a string

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.
Highlighted
Frequent Visitor

Re: Getting random error using substring to extract a string

Hi  

 

Highlighted
Dual Super User II
Dual Super User II

Re: Getting random error using substring to extract a string

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.
Highlighted
Frequent Visitor

Re: Getting random error using substring to extract a string

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?
Highlighted
Frequent Visitor

Re: Getting random error using substring to extract a string

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

Dual Super User II
Dual Super User II

Re: Getting random error using substring to extract a string

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

Helpful resources

Announcements
FirstImage

Microsoft Ignite 2020

Check out the announcement of Power Platform content at Microsoft Ignite!

thirdImage

Experience what's new for Power Automate

Join us for an in-depth look at the new Power Automate features and capabilities at the free Microsoft Business Applications Launch Event.

firstImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (6,946)