Replace / Refresh XPage Field Values Based on Another Field Value

Mindwatering Incorporated

Author: Tripp W Black

Created: 12/16/2011 at 06:19 PM

 

Category:
Notes Developer Tips
XPages

How to refresh, replace, or update field values in an XPage.

With an XPage, you can refresh on field with another and only that section of the page will "blink" and reload. Very convenient and much better than refreshing whole document (form) in the classic environment.

To make one field refresh another using the Server tab (or SSJS-side), select the following properties for the "source" field causing the refresh.
1. Events tab --> Select & Change (lower left) chose onchange --> Server tab (on right) and then do the following:
- Check the checkbox for Process data without validation
- Check the checkbox for Set partial execution mode
2. Under Server Options, click Select Element, choose the ID of the field to update.
3. Save the changes and test the XPage.

Note:
When selecting the ID in step 2 above, you can select a DIV or Table to update a whole section one a value changes.

For the other target field having it's choices or options updated, you might write something like this:
1. Properties tab --> Values --> click the Add Formula Item... buttton.
2. Add an appropriate code snippet. Example:
var tmpLst = new Array();
tmpLst[0] = "Teasers";
if(currentDocument.getItemValueString('CB_DocType')=='WP') {
// leave just Teaser value
} else {
tmpLst[1] = "Content";
}
return tmpLst

Note:
You can also cause the target to hide via its visiblity selection.
Don't forget that in an XPage you toggle when it's visible not when hidden. Example:
1. Properties --> <top first side tab> --> Visible --> Compute --> Write something similar to the following:
if(currentDocument.getItemValueString('CB_Show') == 'T' || currentDocument.getItemValueString('CB_Show') == 'Teasers'){
return true;
} else {
return false;
}


previous page