Macro Methods

Avinash P asked on August 29, 2016 07:56

I have an online form with zip filed. i want to sent the zip field value to custom macro method. i have already have custom macro method. i don't know how to call this method with zip filed value.

i want to know macro expression?

example: CurrentUser.UserName.MyMethod($$label:ZipCode$$);

thanks

Recent Answers


Kristian Bortnik answered on August 29, 2016 09:44

I'm assuming you made a typo regarding $$label:ZipCode$$, since the value would be rendered with $$value:ZipCode$$, and that you are working on the form notification email, not the form layout itself.

You can use macros to access the values, such as {%ZipCode%} instead of $$value:ZipCode$$

In that case, you can pass it to your custom macro method: {%MyMethod(ZipCode)%}

1 votesVote for this answer Mark as a Correct answer

Avinash P answered on August 29, 2016 12:48

Thanks for answer

I want to set the form filed value in this macro method . how can i do?

0 votesVote for this answer Mark as a Correct answer

Kristian Bortnik answered on August 29, 2016 13:33

If you really need to invoke a macro method after the submission of a form, with a value entered in the form, you could add the macro to a

  • Autoresponder template, or
  • Notification template

Honestly this is a bad idea, and you are better off writing a global handler to execute a method upon the submission of a form.

Something along the lines of:

protected override void OnInit()
{
    // Attach a handler to the 'biz form item inserted' event
    BizFormItemEvents.Insert.After += BizFormItem_Insert_After;
}

. . .

private void BizFormItem_Insert_After(object sender, BizFormItemEventArgs e)
{
    // Check if this is the correct form
    if (e.Item.BizFormClassName.ToLower() == "bizform.YourForm") {
        var zipCode = e.Item.GetStringValue("ZipCode");

        // Run your method
        MyClass.MyMethod(zipCode);
    }
}

Another option is to customise the On-line form webpart, which I only recommend as a last resort if all fails.

1 votesVote for this answer Mark as a Correct answer

Zach Perry answered on August 29, 2016 16:04 (last edited on December 10, 2019 02:30)

Are you trying to set the value of the field when the user loads the form?

If so, you can go into admin, edit your form, on the fields tab, click the error to the left of the text box in default value, and insert your macro there, like {%CurrentUser.Email |(identity)GlobalAdministrator%}

0 votesVote for this answer Mark as a Correct answer

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