cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1264
Views
6
Helpful
12
Replies

Updating labels via ISF

David Lucey
Level 1
Level 1

We have a common form component with a lot of rules and a requirement to have a different label on several fields. Rather than create a new AFC and rewrite all the rules, is it possible to update a field label using ISF?

12 Replies 12

Absolutely. You use the setPrompt() function to change the field label:

serviceForm.DictionaryName.FieldName.setPrompt('New Prompt');

ISF is documented in the Active Form Component Guide.

Hi,

Is there any alternative via ISF in JavaScript way?

document.getElementById("DictionaryName.FieldName").setPrompt('New Label') - will it work?

If I am setting the labels programmatically via JavaScript for more than 10 fields selectively among 25 fields, the straight forward option "serviceForm.DictionaryName.FieldName.setPrompt('New Prompt');" will be difficult to manage..

Any help is greatly appreciated! Thanks!!

You can (but not the exactly the way you mentioned). You need to set the label's document element innerHTML.

document.getElementById("DictionaryName.FieldName.Prompt").innerHTML = "New Label:";

BUT...

Why do you think you need to do it this way? Why is it any more or less difficult to manage doing it via ISF vs. direct element manipulation. You should always use ISF when it is available and use direct document manipulation cautiously and only when absolutely necessary.

Hi Derek,

Thanks a lot for your help on this. Since I wasn't aware of this way, I tried accessing the direct JS element manipulation. Is there any material available for ISF other than the designer guide? It would be useful for the development.

Hi, Gunasekaran,

I'm a little confused by your response. The correct method via ISF is (as you pointed out):

serviceForm.DictionaryName.FieldName.setPrompt('New Prompt')

The Designer Guide is your official source for these functions such as this.

Still not sure why you think you need to manipulate the document element directly given there is an ISF function that does the same thing.

Please clarify. Thanks!

Derek

Derek, Sorry if my response confused you. I was about to mention that I haven't tried the innerHTML part of assigning the label.

I was thinking about document.getElementById("DictionaryName.FieldName").value where

document.getElementById("DictionaryName.FieldName.Prompt").innerHTML is the appropriate solution.

Thanks for your help!

Again, even though it is possible to manipulate the innerHTML, why would you want to do that when there is already an ISF function to take care of it (ie, setPrompt)? Is there something special you are trying to do? If anything, the ISF method is LESS cumbersome than the direct element manipulation.

Derek, it is a requirement. I am using a data retrieval rule to pull the company names from backend. I have to show the appropriate products available for the companies. The data in the backend will be updated frequently. So, I have to show the label and the list of products appropriately in a dynamic way. For this requirement, the JS will help me in setting the label. I will use a for loop in JS to set the label for all the companies

Hi Gunasekaran

I believe what Derek is saying here is that calling

document.getElementById("DictionaryName.FieldName.Prompt").innerHTML = "NewVal";

Will achieve exactly the same thing this as using the ISF function as below:

serviceForm.DictionaryName.FieldName.setPrompt("NewVal");

However if the issue here is that you use some dynamic variable (e.g. from your for-loop) to determine the dictionary and field name, then it will be a bit more tricky but you could still use the ISF functions as illustrated below where FieldName and DictionaryName can now become string variables:

serviceForm["DictionaryName"]["FieldName"].setPrompt("NewVal");

Paul/Derek,

I have 25 fields in a dictionary and I am setting the label of the fields dynamically. I have the label names in an array (obtained dynamically while loading the page) and the size of the array. Using the below javascript function, I set the label for all 25 fields.

function setLabel(intArrayLen, strArrayManager) {

for(var intIndex=1; intIndex <= intArrayLen; intIndex++) {

  var strFieldName = "MyDictionary.FieldName_"+intIndex+".Prompt";

  document.getElementById(strFieldName).innerHTML = "" + strArrayManager(intIndex) + "";

}

}

That will work yes, but using the square bracket notation you can still reference the dynamic field names and set the prompt using the ISF functions, the example below should achieve the same thing, but it will obviously work either way. The advantage of using the ISF rules is that if the something does change in the backend in future versions, then it will be handled in the ISF functions, wheres the innerHTML method might need modifications:

function setLabel(intArrayLen, strArrayManager) {

for (var intIndex = 1; intIndex <= intArrayLen; intIndex++) {                serviceForm.MyDictionary["FieldName_" + intIndex].setPrompt(strArrayManager(intIndex));  }

}

Awesome!!! I have changed the code as per your advise. Derek & Paul, Thanks for showing me the correct direction!

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community: