0

My scenario: In document library there are folders which are created automatically. Managers uploads files into them, client approves/rejects those folders as a whole.

Well, setting a workflow which sends email when a document is rejected is not hard. The problem is with the manager which is gonna get the email. How do set the email address of manager? the best option would be [%Current Item:Modified by%] as email address but last user who modified file is client who approved or rejected the folder. How do I choose the user which modified folder before client?

Thanks.

  • Why wouldn't [%Current Item:Created by%] work? – Justin Russell Aug 4 '14 at 22:40
  • As I said, folders are created automatically, which are rejected/approved. not the files in them. If the user would reject/approve files, then this would work. – user3529236 Aug 5 '14 at 6:13
1

Here is my suggestion: Create a Custom Action, either through SharePoint Designer or Visual Studio. The Custom Action should call a JavaScript function that starts a workflow that marks the folder as approved / rejected. The custom action can pass tokens to your JavaScript function ({ItemId} is the only token that works for me from SharePoint Designer). The workflow should have an initiation parameter that contains the managers name. You can use AJAX and SharePoint Web Services to get information from the documents in the folder and start the workflow with the initiation parameter.

The links I provided will give you the basics of gathering all the information and starting the workflow. I've found the most difficult part (and the least documented) is starting the workflow. Here is an example of starting a workflow with an initiation parameter from JavaScript:

function callCompletedWorkflow(poNumber) {
    showInProgressDialog();
    //http://skyliver.ru/blog/item/59
    var listName = "PO%20Requests";
    var itemUrl = getUrlForListItemId(listName);
    var soapEnv =
        "<?xml version=\"1.0\" encoding=\"utf-8\"?> \
<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" \
xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" \
xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"> \
<soap:Body> \
<StartWorkflow xmlns=\"http://schemas.microsoft.com/sharepoint/soap/workflow/\"> \
<item>" + itemUrl + "</item> \
<templateId>" + completedWorkflowTemplateId + "</templateId> \
<workflowParameters><data><poNumberParam>" + htmlEscape(poNumber) + "</poNumberParam></data></workflowParameters> \
</StartWorkflow> \
</soap:Body> \
</soap:Envelope>";
    //get web service url:
    var spsdiscoUrl = $("head link[rel='alternate']:eq(0)").attr("href");
    var spWSUrlPrefix = spsdiscoUrl.substr(0, spsdiscoUrl.length - 13);
    $.ajax({
        cache: false,
        //async: false,
        url: spWSUrlPrefix + "workflow.asmx",
        beforeSend: function(xhr) {
            xhr.setRequestHeader("SOAPAction",
                "http://schemas.microsoft.com/sharepoint/soap/workflow/StartWorkflow");
        },
        type: "POST",
        dataType: "xml",
        data: soapEnv,
        complete: function(msg) {
            if (msg.status == 200) {
                var urlParams = getUrlParams();
                var redirectUrl = 'http://sharepointserver/sites/sharepointsite/';
                if (urlParams.Source) {
                    redirectUrl = urlParams.Source;
                }
                closeInProgressDialog();
                window.location = redirectUrl;
            } else {
                //Failure
                closeInProgressDialog();
                //debugger;
                showStatusBar('Oh no! ' + msg.statusText);
            }
        },
        contentType: "text/xml; charset=utf-8"
    });
}
  • Very helpful post with a lot of good information. I would vote up if I could. However, I managed to solve it without coding, only with workflows. – user3529236 Aug 5 '14 at 16:58
0

If the document creator's e-mail doesn't work, the best way would be to make the creator or an intermediate processor enter the manager's e-mail address in a specific field -- then you can pick their e-mail out of the correct field regardless of if they were the last to edit it or not.

  • Seems pretty good idea, but it would involve a little bit complex workflow which would be hard for me to get working. I imagine it like this: when folder is created in library, it would set a hidden column to manager's name depending on folder name. It would look for the task with same name as folder in task list and it would take manager's name from that task, or just would set the certain email. Sadly, it's quite for me to develop workflows which are running in 2 pages on the same time. Never works for me :/ – user3529236 Aug 5 '14 at 6:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.