web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Extract Ticket Numbers...
Power Automate
Unanswered

Extract Ticket Numbers from an Email Subject

(0) ShareShare
ReportReport
Posted on by 58

So I am circumventing my current Ticket System for the main organization with a Power Automate ticket system for myself. We use Cherwell. 

 

Basically when I get the Cherwell Email from a new Incident, I want to grab that ticket number as well as my personal ticket number which is the ID field of my excel sheet. 

 

Standard Created Ticket:

Incident ID 115740 My Department Cherwell - Test Request - DL#216 1/29/2021 11:49 AM has been created

So the Cherwell Ticket Number is 115740. I want to place that into my excel spreadsheet. The ID field of my excel spreadsheet is 216 (You can see if after 'DL#'). 

 

So I have two COMPOSE Actions:

One to Grab the 115740 so something to look for 'ID ' and grab the 6 digits afterwards

One to look for 'DL#' and I need to get the number between 'DL#' and ' ' so I can get the whole number (It will increase in characters at one point. 

 

I am stumped and have not been able to figure it out. Any suggestions?

 

Finally step is "Update a Row" based on the 216 number ID and drop the 115740 into another field on that row. 

 

 

Categories:
I have the same question (0)
  • v-yiwenxie-msft Profile Picture
    Microsoft Employee on at

    Hi @PlantBasedCajun 

     

    It seems that you want to extract some numbers from an email subject and append them into an excel row.

     

    The whole flow is as below:

    2.8-1.PNG

     

    The detailed steps for ‘Apply_to_each’ are:

    2.8-2.PNG

    Compose: get the 6 digits after ‘Incident ID ’

    Compose 2: return the index of ‘DL#’ in email subject

    Compose 3: return the substring which starts with ‘DL#’

    Compose 4: return the substring between ‘DL#’ and ‘ ’

     

    The functions used are:

    substring(items('Apply_to_each')?['subject'],12,6)

    indexOf(items('Apply_to_each')?['subject'],'DL#')

    substring(items('Apply_to_each')?['subject'],outputs('Compose_2'))

    substring(string(split(outputs('Compose_3'),' ')[0]),3)

     

    After compose, here comes the ‘update the row’:

    2.8-3.PNG

     

    Best Regards,
    Community Support Team _ Kira Xie
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

  • PlantBasedCajun Profile Picture
    58 on at

    So for the GET EMAILS Action, I am using "When a New Email Arrives V3" and they dont have a Value field?

  • PlantBasedCajun Profile Picture
    58 on at

    So I decided to rebuild it your way... Got an error of Compose_3: Unable to process template language expressions in action 'Compose_3' inputs at line '1' and column '21099': 'The template language function 'substring' parameter is out of range: 'start index' must be non-negative integer and should be less than the length of the string. Please see https://aka.ms/logicexpressions#substring for usage details.'.

  • Verified answer
    v-yiwenxie-msft Profile Picture
    Microsoft Employee on at

    Hi @PlantBasedCajun 

     

    If you use 'When a new email arrives V3' as the trigger, then there is no need to use 'apply to each', thus not needing value field.

     

    The newly-arrived email which is used in this case:

    2.9-4.png

     

    The whole flow is:

    2.9-1.PNG

     

    And the functions should be changed a little:

     

    Compose: get the 6 digits after ‘Incident ID ’

    Compose 2: return the index of ‘DL#’ in email subject

    Compose 3: return the substring which starts with ‘DL#’

    Compose 4: return the substring between ‘DL#’ and ‘ ’

     

    The functions used are:

    substring(triggerOutputs()?['body/subject'],12,6)
    indexOf(triggerOutputs()?['body/subject'],'DL#')
    substring(triggerOutputs()?['body/subject'],outputs('Compose_2'))
    substring(string(split(outputs('Compose_3'),' ')[0]),3)]
     
    The detailed step of 'update a row' is:
    2.8-3.PNG
    The outputs of all 4 'compose':
    2.9-2.PNG2.9-3.PNG 
     

    Best Regards,
    Community Support Team _ Kira Xie
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

  • PlantBasedCajun Profile Picture
    58 on at

    Thank you for being so detailed. This worked and i can grab these ticket numbers now. Great Job. 

  • Paulie78 Profile Picture
    8,422 Moderator on at

    Although this is already solved, Thought I would show you another approach, as this seems quite complex to me.

    subjectParse.PNG

    ticketNumber Expression: 

    split(triggerOutputs()?['body/subject'], ' ')[2]

    ID Expression:

    substring(split(triggerOutputs()?['body/subject'], ' ')[10], 3)

    It can be even more simplified than this. 

  • PlantBasedCajun Profile Picture
    58 on at

    interesting... Consolidated to two compose actions. I will check it out. 

  • Paulie78 Profile Picture
    8,422 Moderator on at

    I actually reduced it to one on my side, but kept it as two for simplicity.

  • PlantBasedCajun Profile Picture
    58 on at

    Xnip2021-02-21_06-11-28.png

    So Oddly enough, my "Compose_4" broke and I cannot figure out why. Nothing has changed but I thought I would add the Screenshot

  • Verified answer
    Paulie78 Profile Picture
    8,422 Moderator on at

    You need to look in the run history at the failure, the format of the subject line must have changed.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 522 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 364 Moderator

#3
abm abm Profile Picture

abm abm 243 Most Valuable Professional

Last 30 days Overall leaderboard