K# if-elseif-else statements

John Fu asked on January 15, 2015 23:39

How do you do this in macro expressions?

if (condition) { (expression) } 
else if (condition) { (expression) }
else { (expression) }

I did the following and although it doesn't error out when I put it on the transformation field, it doesn't render using the transformation, instead it renders out the document's fields structure in plaintext.

{% 
doctype = CurrentDocument.DocumentType; 
if (doctype == "custom.DumbPod") {"custom.DumbPod.Default"} 
else {
  if (doctype == "custom.Category") {"custom.Category.DefaultLeftAligned"} 
  else {"custom.MasterDetailPage.Default"} 
}
%}

Correct Answer

John Fu answered on January 16, 2015 01:27

Nevermind.. Apparently that was already working, it's just that my transformations weren't done. Oops

0 votesVote for this answer Unmark Correct answer

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