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

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

Highlighted
Dual Super User III
Dual Super User III

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

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

Hi  

 

Dual Super User III
Dual Super User III

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

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

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

Highlighted
Dual Super User III
Dual Super User III

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
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

Top Solution Authors
Top Kudoed Authors
Users online (2,205)