macro in autoresponder

Ivan Louw asked on October 28, 2019 02:07

Hi Everyone, I am trying to get a value form a page that submitted the form. Indiviually the quiries return values, I am trying to string them together using parameters. I have some success in the conoule app, but when inserting the code into the autoresponder on the form I get an error "An invalid WHERE condition was used". Here is the code: {% Documents["/" + {Documents.Where("NodeId = " + {CurrentDocument.GetValue("SeminarID")})[0].NodeAlias}].Fields.SeminarTime #%}

CurrentDocument.GetValue("SeminarID") returns 582

Documents.Where("NodeId = 582")[0].NodeAlias returns the node alias "xxx-xx-xx"

Documents["/xxx-xx-xx"].Fields.SeminarTime return the time 6:00 pm

Am I doing soming wrong or not using parameters correctly?

Thanks for any feedback!

Recent Answers


Roman Hutnyk answered on October 28, 2019 11:40

Ivan, I'm afraid document data is not available in the context of that operation.

As a workaround you could add an extra field to your form, but hide it with CSS, and populate that field with the document data you need using a macro.

0 votesVote for this answer Mark as a Correct answer

Ivan Louw answered on October 28, 2019 12:22

Hi Roman, I have since found a way to get to the document data. I do have access to nodeid (hidden field on form) via my available fields.

If I use the following I get the field value back

Documents["/Learn-more/More-from-us/Seminars/" + {Documents.Where("nodeID = 582")[0].NodeAlias}].Fields.SeminarTime

but when inserting the node id using the available fields as below, it generates an error.

Documents["/Learn-more/More-from-us/Seminars/" + {Documents.Where("nodeID = " {$$value:SeminarID$$})[0].NodeAlias}].Fields.SeminarTime

`Error while evaluating expression: Documents["/Learn-more/More-from-us/Seminars/" + {Documents.Where("nodeID = " {$value:SeminarID$})[0].NodeAlias}].Fields.SeminarTime |(identity)GlobalAdministrator|(hash)3699787e6539a17f8d99b89e5f32f7db14064e31e3a84060775e48af8b25ece2`

CMS.MacroEngine.LexicalAnalysisException: Lexical analysis of the expression failed. Error near:
ents.Where("nodeID = " {$->>value:SeminarID$})[0].Nod
at CMS.MacroEngine.MacroElement.ParseNext(String expression, Int32& index, Boolean supressError, Boolean isParamValue)
at CMS.MacroEngine.MacroElement.ParseExpression(String expression, Boolean supressError)
at CMS.MacroEngine.MacroExpression.ParseExpression(String expression, Boolean supressError)
at CMS.MacroEngine.MacroResolver.ResolveMacroExpression(ResolveExpressionSettings settings)
But when inserting the available field value the following error is generated.
    Error while evaluating expression: Documents["/Learn-more/More-from-us/Seminars/" + {Documents.Where("nodeID = " {$value:SeminarID$})[0].NodeAlias}].Fields.SeminarTime |(identity)GlobalAdministrator|(hash)3699787e6539a17f8d99b89e5f32f7db14064e31e3a84060775e48af8b25ece2

    CMS.MacroEngine.LexicalAnalysisException: Lexical analysis of the expression failed. Error near:
    ents.Where("nodeID = " {$->>value:SeminarID$})[0].Nod
    at CMS.MacroEngine.MacroElement.ParseNext(String expression, Int32& index, Boolean supressError, Boolean isParamValue)
    at CMS.MacroEngine.MacroElement.ParseExpression(String expression, Boolean supressError)
    at CMS.MacroEngine.MacroExpression.ParseExpression(String expression, Boolean supressError)
    at CMS.MacroEngine.MacroResolver.ResolveMacroExpression(ResolveExpressionSettings settings)

Am I doing somthing wrong or is there another way to get to the value, maybe using CurrentDocument? Thank for the help.

0 votesVote for this answer Mark as a Correct answer

Roman Hutnyk answered on October 28, 2019 13:12

It clearly states it does not like "{$$value:SeminarID$$}".

{$$value:SeminarID$$} - this is not macro syntax, check the documentation.

I believe you should use something like {%SeminarID%}

0 votesVote for this answer Mark as a Correct answer

Peter Mogilnitski answered on October 28, 2019 15:40 (last edited on December 10, 2019 02:31)

Did you try using hidden field in your form?

Normally the syntax is Documents[NodeAliasPath].FieldName For example those should work.

{%Documents.Where("NodeID = 686")[0].NodeAliasPath|(identity)GlobalAdministrator%}

Dont forget about permission sign those as global admin.

0 votesVote for this answer Mark as a Correct answer

Ivan Louw answered on October 29, 2019 03:31 (last edited on December 10, 2019 02:31)

Thanks everyone,

I got it to work. This is the final solution {% Documents["/Learn-more/More-from-us/Seminars/" + {Documents.Where("nodeID = " + {SeminarID})[0].NodeAlias}].Fields.SeminarTime |(identity)GlobalAdministrator%}

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.