HTML field read only crazyness

Tyler Hoge - Gl
Tera Guru

After looking all over the community, wiki, and the hi server knowledge base I couldn't figure out how to make an HTML field read only and when I change a field, it rewrites the contents of the HTML field while still keeping it read only.

Here are the important contents.

1)HTML field variable

2)field that triggers the onChange client script

3) onChange client script

4) UI Policy

I did this for equipment packages as a display table.

HTML field = equipment_package_contains

the UI policy condition is when equipment_package_contains is empty

reverse if flase = true

onLoad = true

UI policy action is to set equipment_package_contains read only = false and Visible = false

Client script

onChange of field

function onChange(control, oldValue, newValue, isLoading) {

  if (isLoading || newValue = '') {

            return;

  }

  g_form.clearValue('equipment_package_contains');

  //you clear the value first to reverse the UI policy

  //Here is where you put your code to build the contents of the HTML field

  //when you are done building the contents, you have to actually do setValue twice or it wont work.

  g_form.setValue('equipment_package_contains', <html value variable>);

  g_form.setValue('equipment_package_contains', <html value variable>);

}

4 REPLIES 4

DrewW
Mega Sage
Mega Sage

So you are trying to have a read only field, then update a different field and that causes the read only field to update?   Or the read only field is updating on its own because it is an HTML field?


I have a choice list of different equipment packages


when this choice changes I build a HTML table with the specific equipment and display it to the user with the HTML field.


I didn't want the user to edit the equipment that is displayed.


I am using the HTML field only to display information.


Oh, so do you need to save the data in the field?   If not then just create a UI Macro that has the base table in it and make sure to give the table an ID and Name.   From there just change your client script to add rows to that table.   You will have to rebuild the display every time the page loads but if its just a few rows I do not think that's a big deal.   I think that would be the easiest way to deal with this.



If you want to still mess with the HTML field idea you mite try dropping the UI Policy and just go to the dictionary entry of the field and mark it read only.


this is in the service catalog. I do need the data to be saved on check out.



I already solved this issue. I am just giving my solution because I couldn't find anything about this that worked.