Cisco Support Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Announcements

Welcome to Cisco Support Community. We would love to have your feedback.

For an introduction to the new site, click here. If you'd prefer to explore, try our test area to get started. And see here for current known issues.

New Member

Updating labels via ISF

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?

Everyone's tags (1)
12 REPLIES
New Member

Updating labels via ISF

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.

Updating labels via ISF

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!!

Bronze

Updating labels via ISF

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.

Updating labels via ISF

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.

Bronze

Updating labels via ISF

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

Updating labels via ISF

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!

Bronze

Updating labels via ISF

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.

Updating labels via ISF

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

New Member

Updating labels via ISF

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");

Updating labels via ISF

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) + "";

}

}

New Member

Updating labels via ISF

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));  }

}

Updating labels via ISF

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

560
Views
6
Helpful
12
Replies