cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Heidi
Level: Powered On

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
Heidi
Level: Powered On

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

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

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.
Heidi
Level: Powered On

Re: Getting random error using substring to extract a string

Hi  

 

Dual Super User
Dual Super User

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.
Heidi
Level: Powered On

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?
Heidi
Level: Powered On

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

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
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

firstImage

Incoming: New and improved badges!

We've given our badges an overhaul and also added some brand new ones!

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Power Automate Community Video Gallery!

Top Kudoed Authors (Last 30 Days)
Users online (6,367)