Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

You can use the functions available within the Custom JavaScript property of a button or field to do calculations, alter attributes, or change values of other fields. Functions such as “formScope.formdata[“InternalVariableName”]” allow you to make use of a value associated with a field within a request or to reference a field to set the value of that field. This can be used to leverage a button to perform actions resulting in transformations of information such as the ability to populate a result to a field from a calculation involving multiple fields.

...

  •  Adding a Button to all requests whose purpose is to execute the calculation
  •  Leveraging that Button through the Custom JavaScript property to populate a field with a value based on fields in the form/request.

Step-by-step guide


  1.  To begin we need to add a button to the form and define it.
  2.  Select Module in the top left banner then select the appropriate module name link.
  3.  Select the Forms tab then select the  name link.
  4.  Select the drop down to the right of Palette, and select Action.
  5.  Drag and Drop the Button from the Palette on the right to the form Canvas on the left.
  6.  Select the edit button from the top right Image Modified of the button within the form editor.
  7.  The text you would like to appear on the button is placed in the field "Placeholder text".
  8.  Next select the Custom JavaScript tab.
  9.  Here you will find the "Click" text box where when a Custom JavaScript script is placed it will be executed upon clicking the button within the form.
  10.  Select Save in the top right.


Custom JavaScript is available on many fields and controls this guide details a specific example on a click action for a button as well as other functions available within the Custom JavaScript library. When using this it isn't to note that it is executing these events as JavaScript and as such requires specific syntax.


Info

This is a Simple example adding the numbers within two fields whose internal names are customNumeric1 and customNumeric2 and setting the resulting sum to customNumeric3

Example -

formScope.formdata["customNumeric3"] = formScope.formdata["customNumeric1"] + formScope.formdata["customNumeric2"];


Info

This is a more complex example involving conditional "if" statements that checks that the field within the statement has a none zero value followed by an else statement to be executed if it does, both statements multiply fields and sets the result to another field.

Example -

if(formScope.formdata["customNumeric4"] !== 0)

{

    formScope.formdata["customNumeric3"] =  formScope.formdata["customNumeric4"]  * formScope.formdata["customNumeric1"];

}

else

{

     formScope.formdata["customNumeric3"] = formScope.formdata["customNumeric2"] * formScope.formdata["customNumeric1"];

}

Filter by label (Content by label)
showLabelsfalse
max5
spacescom.atlassian.confluence.content.render.xhtml.model.resource.identifiers.SpaceResourceIdentifier@8fc
showSpacefalse
sortmodified
reversetrue
typepage
cqllabel = "kb-how-to-article" and type = "page" and space = "HD"
labelskb-how-to-article

...