Can we add client side validation to workflow initiation form (without infopath)?
-
06-10-2020 - |
Question
We are using SP2013 standard so Infopath form service is not available.
By using SharePoint Designer 2013, I copied and renamed the OOB workflow "Approval - SharePoint 2010" to build a new workflow. I have no problem with the logic. Now I want to customize the workflow initiation form.
The requirement is simple:
- Mark some field text in red color;
- If checkbox A is checked, force check checkbox B.
Is there any workaround?
I am considering use Jquery to add some classes. But it may modify other workflow forms since all workflow forms shared url "/_layouts/15/IniWrkflIP.aspx".
Also when I open xoml.wfconfig.xml I can see the form fields. Can I directly modify the XML? If the workflow logic being updated will the xml be ruined?
Solution
I don't think it is an ideal answer but at least it works in my case.
In the system master page, include a Javascript file. Then in the file add follow JQuery script:
var LastPartOfURL = window.location.pathname.split("/").slice(-1)[0].toLowerCase();
if (($.inArray(LastPartOfURL, ['cstwrkflip.aspx', 'wrktaskip.aspx', 'iniwrkflip.aspx']) >= 0){
CustomizeWorkflowForm();
}
CustomizeWorkflowForm is the function to modify your workflow forms with JQuery. Hence, whenever the user browse 'cstwrkflip.aspx', 'wrktaskip.aspx' or 'iniwrkflip.aspx' the function will be triggered.