Look up fields with Required value & Workflow : No Solution ?

Hi,

I'm facing an issue that seems to be impossible to solve.
I have a document library where user upload document. I have 3 columns, one of them is a look up fields.

I set up a workflow to start on item creation : This workflow disable heritage and change document permission.
If i check the lookup fields as a required column, the workflow keeps being on "Starting". Apparently this is because the lookup fields is mark as "required". If I do not mark this column as "required" the workflow will start correctly. (http://blogs.msdn.com/b/chaun/archive/2013/05/16/if-your-sp2010-workflows-are-stuck-in-the-starting-state.aspx)


But i absolutely need this column to be complete. If I don't mark it as required 50% wont populate it, that's unbelievable !

So i will try every piece of solution that you may advise.
I had a look with jquery but i couldn't make it work...

Any help will be hightly appreciated ...

Regards.


  • Edited by infoada33 23 hours 46 minutes ago
July 17th, 2015 3:51am

There is another way to escape from this.

http://morshemesh.blogspot.fr/2012/07/add-empty-option-to-mandatory-lookup.html

I think i shouldn't set the lookup column field as requiered and using jquery or javascript i could check that the column has been populated before enabling save buttton.

But the script isn't compatible with IE-8. If anyone can help me to make it compatible with IE-8 that would be very nice ...

<script type="text/javascript">
var lookupFieldTitle = "IDEntretien";
var cmdSubmit = 'input[id$="_diidIOSaveItem"]';

function MyCustomExecuteFunction()
{
			var selectElement = $("td.ms-formbody select[title='" + lookupFieldTitle + "']");
            selectElement.prepend('')
                         .change(CheckSaveEnabling);
            selectElement.find('option:first-child').attr('selected','selected');
            $(cmdSubmit).attr('disabled','disabled');
			//document.getElementById("Ribbon.ListForm.Edit.Commit.Publish-Large").style.display="none";
			//$("#Ribbon\\.ListForm\\.Edit\\.Commit\\.Publish-Large").prop('disabled','disabled');
}
function CheckSaveEnabling()
{
            var foundEmpty = false;
            $("td.ms-formbody select[title='" + lookupFieldTitle + "']").each(function () { 
                        var list = $(this);
						
                        if (list.find('option:nth(' + list.get(-1).selectedIndex + ')').text() == '(Aucune)')
                        {
							foundEmpty = true;
                        }
            });
            
            if (foundEmpty)
                        $(cmdSubmit).attr('disabled','disabled');
            else
                        $(cmdSubmit).removeAttr('disabled');
}
_spBodyOnLoadFunctionNames.push("MyCustomExecuteFunction");
</script>

Free Windows Admin Tool Kit Click here and download it now
July 17th, 2015 10:29am

Some ideas - when a person uploads a document, it is created, the create workflow runs, then this form pops up - it's an EditForm.  I'd leave the fields as not required, and put code in the EditForm that checks for data and stops the form from completing if data is missing. Something like this

function PreSaveAction() {
   // get data to check
   var field1Data = .......
   var field2Data = .......
   // test for not set
   if(!field1Data || !field2Data) {
       alert('missing info please enter'); // or figure out how to highlight an error on the form instead
       return false;
  } else {
      return true;
}

}
Also note that this form, when you do the save, will *not* run an update workflow. There is SharePoint code that prevents it. You did not mention an update workflow but just in case you need one, you have to do some overrides:

// fix workflow feature that won't start the change workflow.
 var strURL = window.location.href;
 if(strURL.match("Mode=Upload&")) {
 window.location = strURL.replace("Mode=Upload&","");
}
if(strURL.match("Mode=Upload")) {
 window.location = strURL.replace("Mode=Upload","");
}

July 17th, 2015 10:37am

Hi,

It works ! Thank you !!!

<script type="text/javascript">


function PreSaveAction() {
 if (document.getElementById("ctl00_m_g_357482f4_3e6d_4fd0_8070_5e4f59f9c161_ctl00_ctl02_ctl00_ctl02_ctl00_ctl00_ctl00_ctl00_ctl00_ctl04_ctl00_ctl01").value == '(Aucune)')
 { alert ('Merci de renseigner le champs IDEntretien !'); return false; }
 else { return true; } 
}
</script>
Regards

Free Windows Admin Tool Kit Click here and download it now
July 17th, 2015 12:02pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics