Inside Activate
Development
V8 Form Submit Examples
6 min
the form submit function works very differently from previous versions note this document applies to 8 1 or newer the following are some examples of how to do common operations custom validation there are a number of options to show a custom error message to a user set an error message on a specific control this is most useful then the validation relates to a control for example, you may have a custom validation for a name this is shown as an error helper under the control see validatename example below set a page error message this is shown as an alert at the top of the page this is useful when it is a generate error relating to many controls of the page in general see the generatepageerror example below show a custom component you can also choose to dynamically display a help panel or other component instead see customerror example below this sets an error into the job and has a helppanel on the form to display \<helppanel title="=/ error" visible="=!isnull(=/ error)"> \</helppanel> set dynamic data you could also set a dynamic datasource or other dynamic data depending upon a button action see the setresource example below this can set any data into the job which would then change how the controls are generated show a popup message sometimes it is necessary to do something on the server and then show the user a message for example, sending an email and then showing a popup that the email has been sent see the sendemail example below the sendemail2 shows an example of doing an action and returning the previous page while showing a popup message goto the next page it is possible to perform a custom action and then goto the next page automatically see the gotonextpage example below example code using system; using innovation activate; using activate web; using activate web controls; using innovation activate forms xaml; class script webformscript { public void form load(object sender, eventargs e) { provisioningtrace forms("form load"); } public void form submit(activatehttprequest request) { provisioningtrace forms("form submit " + request jobview\ view\ eventsource); if (request iseventsource("generatepageerror")) { request page setpageerror("please select at least one user to request information from "); } if (request iseventsource("validatename")) { string name = job arguments getstring("data/name"); // set an error for the control request page setcontrolerror("txtname1", "can't find user \[" + name + "]"); } if (request iseventsource("customerror")) { job arguments setvalue(" error", "my error"); // the form will be regenerated with the new job arguments } if (request iseventsource("setresource")) { // set resource job arguments setvalue("resource", "=//resources/configuration"); // the form will be regenerated with the new job arguments } if (request iseventsource("sendemail")) { // do something send email etc // return a message and the current job view request page setpopupmessage("email sent"); // form is not regenerated stay on same page } if (request iseventsource("sendemail2")) { request page returntopreviouspage("email sent "); // returns to the previous page and displays the message } if (request jobview\ view\ eventsource == "gotonextpage") { // do something // redirect to the next page page redirecttonextpage(); } } }