Skip to main content
Solved

Pulling Number out of a string


Forum|alt.badge.img+4

I am trying to pull out a record ID # from an email subject or email body.

I want:

Input -     Re: 4793 - New Ticket -...

Output - 4793

Or

Input - 

Should be handled by: Maintenance

Recipients: Maintenance

Ticket #: 4793

Asset ID: empty

 

Output - 4793

 

How can I accomplish this with jinja in a pipeline?

Best answer by GZRServiceAcco

I ended up using a splice to take the first 8 characters minus the first 4.  It won't work on old tickets, but tickets moving forward will work.

Thanks.

View original

MarkShnierYou
Forum|alt.badge.img+24

This can probably be done just with a QuickBase formula. Can you tell me if the format is always the same? For example, if we look for the phrase "Re:" in the subject line, can we be sure that will be there and the following characters will be the number you are looking for?  

 

Then the same for the body content. Can I look for the phrase? Ticket #: and pull out the number following?


JeffRichey47779
Forum|alt.badge.img+4

As Mark suggested, with some simple process guidelines to ensure that Ticket number is always present in the subject line or body of the email you can parse it using a formula field. Standardizing the way that the ticket number is referenced will make your task much easier.

Rather than trying to parse it inside of the pipeline, pass the entire subject or body to a text field in your record then parse it from there.


JeffRichey47779
Forum|alt.badge.img+4

You can use regex on either the body or the subject.

The regex for matching everything that is not # or 0-9 is [^#0-9].


MarkShnierYou
Forum|alt.badge.img+24

GZR .. so you are saying that the data only exists in the pipeline at this point and is not yet in a record?


MarkShnierYou
Forum|alt.badge.img+24

My Jinja is not strong enough to give you the pipelines formula. But often ChatGPT is amazingly good with a Regex formula that could be used in a Pipeline.

But if you have the concept of a Ticket and you are trying to attach child records to that Ticket based on the Ticket number mentioned in the subject or body then you could simply write out the email into the child. Table and I can provide you with a formula on the child table to calculate the [Related Ticket].  


JeffRichey47779
Forum|alt.badge.img+4

Something like RegexReplace([emailbody], "[^0-9]", "")  should work assuming there are no other numbers or # characters present. I am not sure about the exact syntax you will need to use for the reference text.


Forum|alt.badge.img+4

I ended up using a splice to take the first 8 characters minus the first 4.  It won't work on old tickets, but tickets moving forward will work.

Thanks.