Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

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

Recommended Posts

Posted

Hey Guys I've wrote this function but just can't get it to work. The plan is to inject some content (template) and for it to iterate through each word looking for a formula, i.e. {{If([[CarMake]] = "Volvo"; "Volvo" ; "Other" )}} and evaluate it. I think the calculation I have is working fine, but I can't quite manage to work out how to loop through each word in the content. I've tried to reverse engineer Ray Cologens Mail Merge formula as that custom function kind of did what I needed, but I didn't need all of it.

Thanks in advance.

 

 

MergeText(Template)

Let([

start_pos = Position(Template; "{{"; 1; 1);
end_pos = Position(Template; "}}"; start_pos; 1);
formula = Middle(Template; start_pos + 2; end_pos - start_pos - 2);

formula_VARS = Substitute(formula ; 

    ["[[CarMake]]";"$CarMake"];

    ["[[CarModel]]";"$CarModel"];

    ["[[CarType]]";"$CarType"]
);

original_formula = "{{" & formula & "}}";

evaluated_formula =  If(EvaluationError(Evaluate(formula_VARS)); "Invalid Formula"; Evaluate(formula_VARS))
]
;


Case(
    Right(Template ; 1 ) <> ¶ ; MergeText(Template & ¶) ;

    start_pos > 0 and end_pos > start_pos ; MergeText(Substitute (Template ; original_formula ; evaluated_formula ) ) ;

Template

    )

)

 

 

This topic is 3104 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.