Question

I am working on a SharePoint On-Premises 2013 farm. and inside my Create & Edit form, i want to set a Status Choice field as read-only, then later on to chnage its value inside a JavaScript script.

Now i am using SPUtility.js to make my Status field as ReadOnly, as follow:-

SPUtility.GetSPFieldByInternalName('OrderStatus').MakeReadOnly();

But when i try to set its value inside my JavaScript as follow (so when user check a checkbox named "Order Start Working", to set the Status = "In Progress"):-

$('[id^="OrderStartWorking"][id$="RadioButtonChoiceField0"]').change(function(){
SPUtility.GetSPFieldByInternalName('OrderStatus').SetValue("In Progress");
});

OR using pure JavaScript appraoch:-

$('[id^="OrderStartWorking"][id$="RadioButtonChoiceField0"]').change(function(){
$('[id^="OrderStatus"]').val("In Progress");
});

the value did not change to "In Progress"

So I am not sure how i can set a value for a read-only choice list OR if i can remove the ReadOnly from my choice list >> then set its value = "In Progress" >> then make it as ReadOnly again. keeping in mind that i do not want to set the Status choice list as disabled using JavaScript, since in this case the value will not get submitted when i save the Edit/Create forms.

Was it helpful?

Solution 2

As mentioned in @mannaggia comment.. MakeEditable() it worked well for me

OTHER TIPS

Read only fields aren't rendered on New/Edit form. Remove read only from choice list.

disable the field on form and set its value using jquery

$("#FieldId").prop("disabled", true);
$("#FieldId").val('valuetoset');
Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top