How to set ReadOnly for all fields in GlideModalForm

felladin
Tera Guru

I am creating a UI Macro to present a form (similar to sys_popup) using GlideModalForm.
Everything works as it should except two thing; I want all fields to be readonly and I'd like UI Actions to not be present.

As GlidePopup isn't active anymore, I was hoping there was a parameter or preference to add to the modal query, but unfortunately the location of documentation for all the different parameters and preferences eludes me. The ones mentioned in the developer API pages are too general to be of assistance.

I was thinking of creating a specific view for this, but I feel there should be an easier way.
And the GlideModalForm boolean for hiding the close button is not the answer here.

With regards
Anton Vettefyr

My very much new script that I made to test what I found:

<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<g:evaluate var="jvar_guid" expression="gs.generateGUID(this);" />
<j:set var="jvar_n" value="show_changes_${jvar_guid}:${ref}"/>
<g:reference_decoration id="${jvar_n}" field="${ref}"
  onclick="showCIRecordForm('${ref}'); "
  title="${gs.getMessage('Configuration item')}" image="images/icons/tasks.gifx" icon="icon-tree-right"/>

<script>
	function showCIRecordForm(reference){
	  var show = new GlidePopup('Showing CI form','cmdb_ci_computer',receivedData,false);
	  show.setSysID(g_form.getValue(reference));
	  show.addParm('sysparm_view','default_view');
	  show.addParm('sysparm_view_forced','true');
	  show.addParm('sysparm_form_only',true);
	  show.render();
	}
        // This does nothing, as per design	
        function receivedData(data){
	  g_form.addInfoMessage('/// Server shown');
	}

</script>
</j:jelly>
2 REPLIES 2

Omkar Mone
Mega Sage

Hi 

Try the below script to make fields read-only.

 

var fields = g_form.getEditableFields();
for (var x = 0; x < fields.length; x++) {
    g_form.setReadOnly(fields[x], true);
}

 

Mark Correct if it helps.

Warm Regards,

Omkar Mone

find_real_file.png

www.dxsherpa.com

Hello,

I tried that before but was hoping there was a good way to solve this.

It appears the issue with the buttons will be hard. At the moment it seems the only solution is to create a specific view and then set the buttons to not appear for that view.

$$('BUTTON') only targets the original record.

Regards
Anton