This project has moved and is read-only. For the latest updates, please go here.

GetGroupCollectionFromUser loosing data

Feb 8, 2012 at 11:07 AM


I run in to the issue using GetGroupCollectionFromUser if user is in the Group A then disable input to the column. However, here is my problem when user is not within this group and submit (EditForm) the item the data from the disabled columns (single line text) is wiped out. Any idea what is wrong?


<script type="text/javascript">

 $(document).ready(function() {


      operation: "GetGroupCollectionFromUser",

      userLoginName: $().SPServices.SPGetCurrentUser(),

      async: false,

      completefunc: function(xData, Status) {

        if($(xData.responseXML).find("Group[Name='A']").length == 1) {


$(document).ready(function() {

$("select[title='Q Status']").attr('disabled','disabled');
$("input[title='Date Requested']").attr('disabled','disabled');
$("input[title='Date Received']").attr('disabled','disabled');
$("input[title='Date Entered']").attr('disabled','disabled');
$("select[title='Tooling Required']").attr('disabled','disabled');







Feb 8, 2012 at 3:04 PM


If you disable columns, those values will not be submitted with the form. What I usually do is reenable to fields in the PreSaveAction before submitting.

Above, you are disabling the columns regardless of what you get back from the Web Service call because you have thing wrapped in a $(document).ready().


Feb 8, 2012 at 4:19 PM


Thank you for your advice Marc :) never thought about this :/ I use quite a lot of SPServices in my projects and I think you did a brilliant job ;)




Feb 8, 2012 at 4:36 PM



Feb 10, 2012 at 2:17 PM


Have you tried to use "readonly" instead of "disabled"?  Readonly will not allow the user to edit its content, but will still submit the field information when the form is submitted...In addition, you can also attach css styling to give the fields a "disabled" look... or make it look like regular text... example:

$("input[title='Vendor']").attr('readonly','readonly').css("color", "grey");

Note: if you are using a newer version of jQuery, you may want to use .prop() when setting a field to disabled (or checked for checkboxes)... the behaviour between .attr() and .prop() changed in a recent version of jQuery (1.6 maybe? don't remember)


Paul T

Feb 13, 2012 at 3:12 PM


I have tried your solution. However, it doesn't come very good with GetGroupCollectionFromUser. For some reason doesn't apply restriction and you still can edit fields if you are not within the group :( I have used attr() haven't tried prop() . Anyway thanks for your help.