cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
y2kardell
Helper III
Helper III

Help Displaying Last 4 Digits/Characters of a Tracking Number

Hi-

I am having to create a flow using power automate that requires the following:

User inputs a tracking number in a SharePoint column, I need to figure out how using power automate

to capture the last 4 digits or characters of the input tracking number value and display it into another column

in another Sharepoint list but for now just need the function of how to achieve this.

Any help is appreciated,
y2kardell

1 ACCEPTED SOLUTION

Accepted Solutions

Doing it with hidden SharePoint column would have been easier.  Please mark the original solution as accepted.

@y2kardell 

Pat

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about the Power Platform, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


View solution in original post

23 REPLIES 23
mahoneypat
Solution Sage
Solution Sage

You can use an expression like this.  Replace 'abcdefg' with your Dynamic Content in both places.

 

substring('abcdefg', sub(length('abcdefg'),4),4)

 

Pat

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about the Power Platform, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


y2kardell
Helper III
Helper III

Hey Pat-

Thanks for the feedback I really appreciate it, I just have another question, exactly where would I use the substring function that you mentioned? Currently I have 2 lists with a column called "Tracking#" on both lists and the idea is that I want to take for example "123344455" and extract the last 4 digits (in this case 4455) and use a create and update to dump the value into another column called "Tracking Last 4). 

Any further help is always appreciated.

 

Thanks,

y2kardell

You can use that expression wherever you would use that value. For example, in the Create/Update SharePoint item action for the last 4 characters field. Instead of adding dynamic content, click on Expression instead and enter the substring, using the dynamic content field in place of 'abcdefg'.

 

Also, I noticed that you posted this question again.  FYI that you can @ mention someone in your response to make sure they get notified.

 

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about the Power Platform, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


@mahoneypat  I think I am still having issues, here is what I am seeing:

in the Create and Update item action fields I have a column called 'Tracking (Last 4).

In the expressions box here is what I entered '@{substring('Tracking #', sub(length('Tracking #'),4),4)}'.

When I did so, the output I received back was: 'ng #'.

Any ideas what I ama doing wrong? The value that I entered in the column box called 'Tracking #' was '12345678'.

 

Thanks again for your help,

y2kardell

mahoneypat
Solution Sage
Solution Sage

When you add just the Tracking # field directly and hover over it, you will see an expression like item()['Tracking #']. Use that expression in place of 'Tracking #' in your expression.

Pat

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about the Power Platform, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


@mahoneypat I'm not sure that I quite follow where you are saying that should be applied. I am attaching a partial screenshot of my flow for you to point out where exactly and for further clarification. 

Thanks again for the help,

y2kardellInkedTicket.jpg

mahoneypat
Solution Sage
Solution Sage

Without seeing the actual expression, your pic looks correct.  Is it working?

Pat

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about the Power Platform, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


@mahoneypat it's not....I don't think that I have the expression correct. When I run the flow...it's giving me 4 characters being.......'ng #' instead of the last four digits of the tracking number like it's supposed to. My question is that you mentioned using [] but I'm not sure of the exact syntax in the expression.

y2kardell
Helper III
Helper III

@mahoneypat this is the expression I used:

substring('Tracking #', sub(length('Tracking #'),4),4) 
not sure if this is where or how the [] should be used according to your suggestion to give me the last 4 digits of any given tracking number the approver inputs.
Thanks.
mahoneypat
Solution Sage
Solution Sage

You are passing static text of 'Tracking #', when you need to pass a dynamic expression.  In your pic, hover your mouse over the green Tracking # field you added and note the expression shown.  Use that in place of 'Tracking #' in both places in your expression.

 

Pat

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about the Power Platform, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


y2kardell
Helper III
Helper III

@mahoneypat  this was what showed up in the 'Tracking #' field when I hovered:

triggerOutputs()?['body/Tracking_x0023_']

 

I tried this: 

substring('body/Tracking_x0023_', sub(length('body/Tracking_x0023_'),4),4)
and output was: 023_. I even tried the [] around['body/Tracking_x0023_'] and it kept saying 'invalid expression'.
Any thoughts?
Sorry to keep asking questions in regards to this.
y2kardell
mahoneypat
Solution Sage
Solution Sage

You need to use the whole thing.  This should be your final expression.

 

substring(triggerOutputs()?['body/Tracking_x0023_'], sub(length(triggerOutputs()?['body/Tracking_x0023_']),4),4)

 

Pat

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about the Power Platform, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


y2kardell
Helper III
Helper III

@mahoneypat  ok so this seems to give me a 'flow run failed' message after adding the substring function you mentioned when I save the initial sharepoint list, but then when I modify it, it gives the expected results. Here is the error message I am gettting.Error.png

VictorIvanidze
Community Champion
Community Champion

You have to check if triggerOutputs()?['body/Tracking_x0023_'] is null.

--------------------------------------------------------------------------------------
Contact me if you are interested in custom Power Automate development.

@VictorIvanidze @mahoneypat 

The value is 0 until the approver goes back in to edit the form to input the tracking number in the tracking # column. Initially when the shipper submits the shipping request.....it is 0 because it's obvious the shipper won't know the tracking number at that point.

y2kardell
Helper III
Helper III

@VictorIvanidze @mahoneypat I guess my main question is....how do i check a field is NULL or not?

VictorIvanidze
Community Champion
Community Champion

Hi @y2kardell,, just use empty() function.

--------------------------------------------------------------------------------------
Contact me if you are interested in custom Power Automate development.
y2kardell
Helper III
Helper III

@VictorIvanidze  @mahoneypat  when I use: 

@empty(triggerbody()?['body/Tracking_x0023_']) in the condition statement, I get 'The expression is invalid'.

Any ideas?

I even took out the single quotes and typed them in again with the same issue.

Thanks again for the help,

y2kardell

 

You need to add the ? in to protect against the case when it does not exist.  Here is an example

 

if(empty(triggerBody()?['text']), '', substring(triggerBody()['text'], sub(length(triggerBody()['text']),4),4))
 
Pat
 




Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about the Power Platform, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

New Ideas Forum MPA.jpg

A new place to submit your Ideas for Power Automate

Announcing a new way to share your feedback with the Power Automate Team.

MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

Super User 2 - 2022 Congratulations 768x460.png

Welcome Super Users

The Super User program for 2022- Season 2 has kicked off!

Users online (4,395)