Difference between revisions of "Sbfunc"

From SmartWiki
Jump to: navigation, search
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 +
{{JavaScript Syntax}}
 
You can use '''sbfunc''' to create a custom [[Browser Script]] that runs whenever a user clicks '''Save''' or '''Submit''' for {{l1}}, {{l2}} and {{l3}} records only.
 
You can use '''sbfunc''' to create a custom [[Browser Script]] that runs whenever a user clicks '''Save''' or '''Submit''' for {{l1}}, {{l2}} and {{l3}} records only.
 
* ''Similar to '''savefunc''' but '''sbfunc''' does not run on '''Save Draft'''
 
* ''Similar to '''savefunc''' but '''sbfunc''' does not run on '''Save Draft'''
Line 6: Line 7:
 
* Include a function in the [[Browser Script]] called '''sbfunc''' that includes the [[JavaScript]] you wish to execute when the record is either saved or submitted.
 
* Include a function in the [[Browser Script]] called '''sbfunc''' that includes the [[JavaScript]] you wish to execute when the record is either saved or submitted.
 
* The function must return either a value of '''true''' if the record should be saved/submitted; or '''false''' if the record should not be saved/submitted.
 
* The function must return either a value of '''true''' if the record should be saved/submitted; or '''false''' if the record should not be saved/submitted.
* Standard and Custom Field validations are performed '''before''' the sbfunc script is run, so if the function returns '''true''' the record immediately be saved/submitted. If the function returns '''false''' no further validation is performed and the record is <u>not</u> saved/submitted.
+
* Standard and Custom Field validations are performed '''before''' the sbfunc script is run, so if the function returns '''true''' the record will immediately be saved/submitted. If the function returns '''false''' no further validation is performed and the record is <u>not</u> saved/submitted.
 +
* When you enable '''Bypass Validation''' on a submit button sbfunc will be ignored.
  
  

Latest revision as of 14:56, 13 May 2014

This feature uses JavaScript syntax
Text code javascript.gif

You can use sbfunc to create a custom Browser Script that runs whenever a user clicks Save or Submit for Level 1, Level 2 and Level 3 records only.

  • Similar to savefunc but sbfunc does not run on Save Draft

Instructions:

  • Create a Custom Field on the page of type: Custom Field Type: Special – Browser Script
  • Include a function in the Browser Script called sbfunc that includes the JavaScript you wish to execute when the record is either saved or submitted.
  • The function must return either a value of true if the record should be saved/submitted; or false if the record should not be saved/submitted.
  • Standard and Custom Field validations are performed before the sbfunc script is run, so if the function returns true the record will immediately be saved/submitted. If the function returns false no further validation is performed and the record is not saved/submitted.
  • When you enable Bypass Validation on a submit button sbfunc will be ignored.


Example 1:

function sbfunc(frm)
   {
    do this
    RunAnotherFunction()
    do that
    return true
   }



Example 2:

  • The following sample JavaScript function will prompt the user to confirm if they really want to save the record.
function sbfunc(frm)
{
var answer = confirm ("Do you really want to save this?")
if (answer)
   {
   alert ("Consider it done")
   return true
   }
else
   {
   alert ("Keep filling it in then")
   return false
   }
}
  • The "return false" isn't strictly necessary. If the function does not return true then false is assumed.

See Also