rbf_getFieldValue not working on View Pages

Posted by Meryk on 30-Jul-2015 10:15

Hello,

Something very basic here : I am calling rbf_getFieldValue(fielName) function in Both Edit and View pages, on different types of fields (text, picklist, lookup..).

It is returning the correct values on the Edit page, but it keeps returning NULL on the View page.

Is that a bug or am I doing something wrong?

Thank you

Mery

Posted by Godfrey Sorita on 30-Jul-2015 15:02

Perhaps you can change the way you use your hosted file scripts. If the script is intended to be used on both view and edit page, it should be designed to accept parameters from either page.

Sample script of hosted file:

var value;
function getFieldValue(objName, id, fieldName, pageType) {
  if (pageType == "edit") {
    value = rbf_getFieldValue(fieldName);
  } else if (pageType == "view") {
    rbf_selectValue("SELECT " +fieldName+ " FROM " +objName+ "WHERE id = " +id, function(data){
       value = data;
    })
  }
}

Sample script of edit page:

getFieldValue(null, null, "firstName", "edit");

Sample script of view page:

getFieldValue("myObject", "{!id}", "firstName", "view");


All Replies

Posted by Godfrey Sorita on 30-Jul-2015 10:34

Please use field tokens to return the values in view pages. There is no need to use rbf_getFieldValue because the values you are retrieving is already stored in the database.

Example:
var firstName = "{!firstName}";

The function rbf_getFieldValue() retrieves the current values from input elements. Hence, this function should only be used on new/edit pages.

Posted by Meryk on 30-Jul-2015 10:59

I am not using Tokens because they don't work in Hosted Files.

Basically I have this code in a Hosted File, and Tokens are not resolved properly from these files from our experience. Please correct me if I am wrong..

Can you suggest an alternative solution to get the values of any field in the page from the Hosted File? In a way that would be applicable to both View and Edit pages, as we are using the same hosted file for both pages.

Thank you

Mery

Posted by Godfrey Sorita on 30-Jul-2015 15:02

Perhaps you can change the way you use your hosted file scripts. If the script is intended to be used on both view and edit page, it should be designed to accept parameters from either page.

Sample script of hosted file:

var value;
function getFieldValue(objName, id, fieldName, pageType) {
  if (pageType == "edit") {
    value = rbf_getFieldValue(fieldName);
  } else if (pageType == "view") {
    rbf_selectValue("SELECT " +fieldName+ " FROM " +objName+ "WHERE id = " +id, function(data){
       value = data;
    })
  }
}

Sample script of edit page:

getFieldValue(null, null, "firstName", "edit");

Sample script of view page:

getFieldValue("myObject", "{!id}", "firstName", "view");


Posted by Meryk on 05-Aug-2015 09:17

Thank you, I did something like what you suggested and it is working.

Mery

This thread is closed