cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
martinav
Resident Rockstar
Resident Rockstar

More OData help - simple left() right() text parsing routines.

This is so easy in excel... why the h these guys use this odata garbage, I will never know... but I am trying to do something very simple, in thought.  Can someone help me write the odata routine that I can put into a Set Variable action?

 

Column: Filename = 123456-r1.pdf

 

I need to set two variables from this same basic filename structure.

 

Variable: PartNumber

Variable: Revision

 

Partnumber = 123456 (all of the numbers up to and not including the "-")

 

Revision = 1 (the one or two digit number between the "r" and the ".")

 

In excel, I would write:

(A1)=123456R-r5.pdf

(A2)=SEARCH(".pdf",A1) = 11

(A3)=SEARCH("r",A1,A2-3) = 9

PartNumber=LEFT(A1,A3-2) = 123456R

Revision = MID(A1,A3+1,A2-A3-1) = 5

 

It would likely take me two full days to figure out all of the syntax required to do this simple task.  I beg for help from anyone that has some sympathy for my plight!

 

Thank you.

 

1 ACCEPTED SOLUTION

Accepted Solutions
martinav
Resident Rockstar
Resident Rockstar

Ok, it took a bit less time than I expected.  Lucky this time.  Forunately, expression builder is more advanced than I thought.  It is still cryptic as hell.  I was blown away by the inability to do simple add/sub.  Had to wrap add() or sub() around things to do that.  wow...  What saved me wsa the lastIndexOf function.  The ability to search form the right made it much easier.

 

To find the last "r", I used Set Variabe "Find-r":  

lastIndexOf(body('Get_file_metadata')?['Name'],'r')

 

 To find the last ".", I used Set Variable "Find Dot":  

lastIndexOf(body('Get_file_metadata')?['Name'],'.')

 

To get part number, I wrote: 

substring(body('Get_file_metadata')?['Name'],0,add(variables('Find-r'),-1))

 

Toi get the revision number, I wrote: 

substring(body('Get_file_metadata')?['Name'],add(variables('Find-r'),1),sub(sub(lastIndexOf(body('Get_file_metadata')?['Name'],'.'),lastIndexOf(body('Get_file_metadata')?['Name'],'r')),1))

 

View solution in original post

2 REPLIES 2
martinav
Resident Rockstar
Resident Rockstar

Ok, it took a bit less time than I expected.  Lucky this time.  Forunately, expression builder is more advanced than I thought.  It is still cryptic as hell.  I was blown away by the inability to do simple add/sub.  Had to wrap add() or sub() around things to do that.  wow...  What saved me wsa the lastIndexOf function.  The ability to search form the right made it much easier.

 

To find the last "r", I used Set Variabe "Find-r":  

lastIndexOf(body('Get_file_metadata')?['Name'],'r')

 

 To find the last ".", I used Set Variable "Find Dot":  

lastIndexOf(body('Get_file_metadata')?['Name'],'.')

 

To get part number, I wrote: 

substring(body('Get_file_metadata')?['Name'],0,add(variables('Find-r'),-1))

 

Toi get the revision number, I wrote: 

substring(body('Get_file_metadata')?['Name'],add(variables('Find-r'),1),sub(sub(lastIndexOf(body('Get_file_metadata')?['Name'],'.'),lastIndexOf(body('Get_file_metadata')?['Name'],'r')),1))

 

View solution in original post

martinav
Resident Rockstar
Resident Rockstar

Nice solution... thank me very much!! 😄

Helpful resources

Announcements
Process Advisor

Introducing Process Advisor

Check out the new Process Advisor community forum board!

MPA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Top Solution Authors
Top Kudoed Authors
Users online (29,376)