Jump to content
Server Maintenance This Week. ×

Get contents of multiple merge fields in text field


This topic is 2530 days old. Please don't post here. Open a new topic instead.

Recommended Posts

I'm stuck in my thinking.... How would I go about evaluating (getting the content) of multiple fields specified as merge fields in a text field?

 

For example:

"Name: " & <<Name>> & ", " & "Category: " & <<Category>> & ¶ & "Type: " & <<Type>>

 

Which would result in:

"Title: MyRecordName, Category: MyCateogry

MyType"

 

Any input most appreciated!

Edited by artvault
Link to comment
Share on other sites

"Name: " & Table::Name & ", " & "Category: " & Table::Category & ¶ & "Type: " & Table::Type

Table being whatever table the field is coming from

or if it's in an auto enter calculation where the text field is in the same table

"Name: " & Name & ", " & "Category: " & Category & ¶ & "Type: " & Type

Link to comment
Share on other sites

I am afraid you are confusing two different techniques. The term "merge fields" is used for fields you place inside a text block on a layout - not in the context of a calculation. In your example, you would simply type the following directly onto the layout:

Name: <<Name>>, Category: <<Category>>
Type: <<Type>>

If for some reason you need the same result within a calculation field, use the following formula =

"Name: " & Name & ", Category: " & Category & "¶Type: " & Type

 

 

Edited by comment
Link to comment
Share on other sites

Thank you so much for your replies! I should have explained the context better, my apologies.

I would like users to be able to enter a combination of  descriptive text and field names into one single text field, combined with commas and line breaks. I would then want use a calculation/script step that evaluates all of the content of the text field and "pulls-in" information from the referenced fields (hence my usage of the term merge fields, which I realize was not accurate). The syntax of the text field is flexible, what ever works best.

I know I can use Evaluate () but I'm not sure how I have to structure this for it to handle multiple fields and "plain text" content. 

For example, let's assume that users would type into a text field: 

"Name: " & Name & ", Category: " & Category & "¶Type: " & Type

How would I evaluate/process this altogether? As a chunk?

Edited by artvault
Link to comment
Share on other sites

17 minutes ago, artvault said:

For example, let's assume that users would type into a text field: 


"Name: " & Name & ", Category: " & Category & "¶Type: " & Type

How would I evaluate/process this altogether?

If you had a user smart enough to type exactly that into a text field, then Evaluate ( YourTextField ) would produce the expected result. 

There are other options, depending on what your users may find convenient. For example, they could type the text as text, not as a calculation formula, and merge the fields inside the text - the same way you would, if placing the text on a layout (as shown in my first example). Then you would use a recursive custom function (or a looping script) to find the merged fields and replace them with the corresponding values. Or, if the list of fields they can use is limited and known in advance, use the Substitute() function to do the "merging".

 

Edited by comment
Link to comment
Share on other sites

Ha! Now it works!

I had a typo in the text I typed, which resulted in a "?" - which proves your point exactly: if I can't trust myself, how can I trust my users to type correctly... I will look into a recursive custom function, as there are quite a lot of fields to choose from.

Thanks again for pointing me in the right direction!

Link to comment
Share on other sites

This topic is 2530 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.