cancel
Showing results for 
Search instead for 
Did you mean: 
Workflow Hero

Disabling a field after submission

I have a form that I am looking to disable fields for anyone that is not part of a group (QA Submission) in this case after it has been submitted (no ability to edit). I have created a calculated column that flips from 0 to 1 (hidden field) once submitted. I want to use that, as well as the logic fn-IsMemberOfGroup(QA Submission).So basically, once a form is submitted, it checks the submission status and if they are not a member of the QA Submission group disables the field.

Logic to check for status {ItemPropertySmiley Frustratedubmitted}!="0"

Logic to check for group. I just cant figure out the NOT (!, not, etc) function and the ability to combine them into one. fn-IsMemberOfGroup(QA Submission)

Can anyone help combine these functions into one? As always, thank you for your help and I hope everyone has a wonderful day.

Tags (1)
0 Kudos
Reply
2 Replies
Workflow Hero

Re: Disabling a field after submission

you can try this JavaScript code.

var userTitle;
NWF$(document).ready(function()
{  
 NWF$("#" + control).attr("disabled", true); //disable controls here for all users
 GetCurrentUsername();
}
);
function GetCurrentUsername()
{
 var ctxt = new SP.ClientContext.get_current();
 this.website = ctxt.get_web();
 this.currentUser = website.get_currentUser();
 ctxt.load(currentUser);
 ctxt.executeQueryAsync(Function.createDelegate(this, this.onSucceess), Function.createDelegate(this, this.onFail));
}
function onSucceess(sender, args)
{
 userTitle = currentUser.get_title();
 retrieveSPGroupMembers();
}
function retrieveSPGroupMembers()
{
 var clientContext = new SP.ClientContext.get_current();
 var colGroup = clientContext.get_web().get_siteGroups();
 var approverGroup = colGroup.getByName("Owners");
 this.colUsers = approverGroup.get_users();
 clientContext.load(colUsers);
 clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));
}
function onQuerySucceeded(sender, args)
{
 var userEnumerator = colUsers.getEnumerator();
  var userNames="";
  var userName="";
 while (userEnumerator.moveNext())
 {
  var oUser = userEnumerator.get_current();
  userName = oUser.get_title();
  userNames = userName + ";" +userNames;
  if(userName == userTitle)
  {
   var status = NWF$("#" + status).val();
   if(status == 'Submitted')
   {
      alert('success');
      NWF$("#" + control).attr("disabled", false); //enable controls here for logged in user who is part of Owner group
    }
  }
 }
}
function onQueryFailed(sender, args)
{
 alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
}

Change your SP group Name instead of 'Owners' and status, control names with your field javascript control names.

0 Kudos
Accept as Solution Reply
Workflow Hero

Re: Disabling a field after submission

Hi,

did you use a SharePoint group or AD group in the function fn-IsMemberOfGroup ?

If you are in 365, the function only works for SharePoint group

Accept as Solution Reply