Help

Attachment formula - len

Topic Labels: Formulas
1093 3
cancel
Showing results for 
Search instead for 
Did you mean: 
Scott_Gardner1
7 - App Architect
7 - App Architect

Hello-

I have this formula:

IF({DESIGN: UNDER REVIEW},SUBSTITUTE(
RIGHT(‘’&{DESIGN: UNDER REVIEW},1+
LEN(‘’&{DESIGN: UNDER REVIEW})-FIND(‘https:’,‘’&{DESIGN: UNDER REVIEW},LEN(‘’&{DESIGN: UNDER REVIEW})-133)
),‘)’,‘’
))

And what it does is it takes 20 files in one cell and extracts the latest image in on the right to always show in a new field. The issue is that it’s not recognizing some and the URL is blank that I am using the automation.

Does it matter if I have PNG, PDF, MP4, GIF files all in one - wonder if that is causing it to break.

Thank you!

3 Replies 3

Hi @Scott_Gardner1,
I wasn’t able to get your formula to not work.

I slapped together this script to allow you to review all of the URLs in an attachment field, maybe this can help you find your issue

let table = await input.tableAsync('Pick a table');
let field = await input.fieldAsync("Pick a field", table);
let queryResult = await table.selectRecordsAsync({fields: [field]});
let record = queryResult.getRecord(queryResult.recordIds[0]);
output.inspect(record.getCellValue(field));

Hi,
On a brief look formula removes closing bracket at the end and searching for ‘http:’ from the position 133 chars back from the end, supposing a single link together with filename can easily fit into this interval, but not two links. Is it dejavu or I wrote something like this some time ago, as a quick fix?
of course, such approximation may sometimes fail when attachment has too long file name.
i have seen a way to find exact position. find number of attachments (by substitute commas or http and then compare length). then use this number in substitute http, fourth parameter (means instead of replace all, replace only given occurence.

but that’s too long, and i was lazy enough to try understanding some regex formulas here. And when i got it (at least part of them),I can change it according to my goal. In your case, it’s

REGEX_EXTRACT({Attachments}, “[^,]*$”)

Scott_Gardner1
7 - App Architect
7 - App Architect

Thank you! I changed the Char to -300 and it worked.