5

I am currently working with SharePoint 2007 designer. But I am having a issue creating a workflow that scans for a certain item that appears more than once in different items. Here is a picture of something similar to what im working with enter image description here

Now what I need to do is create a workflow such that when the same Type and Action appears consecutively in three months of a row and the risk has to be >=10% it creates a new item in another list with comment stating "We have noticed for the past 3 months the risk for this action... has been >=10%...". I have created the last part already but I am stuck trying to get my workflow to scan continuously for these items. Any help would be great thanks.

2
  • With 2007, you're likely going to need to do this in a timer job or event receiver. Workflows aren't going to get you the functionality you need in this case. – Eric Alexander Jul 24 '14 at 23:00
  • Your other option is to create a new Action for SharePoint designer, but I would suggest you rather do it with the Timer Job or Event receiver as suggested by PirateEric – JP Roelofse Jul 25 '14 at 6:20
6
+100

Here is the solution:
Challenges: The requirement needs to be achieved only using Out of the Box solution. And SPD workflow does not give any feature to scan multiple list items.

Solution: Since MOSS 2007 SPD Workflow has very few actions, we can not achieve the whole solution using SPD Workflow. So we need to populate the List Item so that most of the calculation is done in the List Form instead of workflow.

ECM Master List:

  • Title
  • CType(Not able to store Type named column)
  • Action
  • Report Date
  • %Risk
  • CurrentMonth: This is new column which will store the Current Item's Match String. This will be populated by JavaScript in the List Form. User's need not to put any data into it. This will be hidden in the form.
  • Prev1Month: This is new column which will store the Previous 1 Month's Match String. This will be populated by JavaScript in the List Form. User's need not to put any data into it. This will be hidden in the form.
  • Prev2Month: This is new column which will store the Previous 2 Month's Match String. This will be populated by JavaScript in the List Form. User's need not to put any data into it. This will be hidden in the form.

Note: Match String is a string by which I will check CType, Action, Month and Year at one shot.

Step 1: Create Custom New Form which will auto populate the CurrentMonth, Prev1Month and Prev2Month.

  • Create a Custom New Form: Go to SharePoint Designer and Epand the Lists > ECM Master List
  • Copy the NewForm.aspx and Paste it in the same location and rename it as CustomNewForm.aspx enter image description here
  • Open CustomNewForm.aspx by double clicking on it.
  • Select the Web Part and Delete it enter image description here enter image description here
  • Now Go to Insert > SharePoint Controls > Custom List Form and Click it enter image description here
  • Select 'ECM Master List' and Content Type as 'Item' and Select 'New item form' and click on 'OK' button enter image description here
  • Now in the code find the oneIDListForm and put the following reference
<script src="/Shared%20Documents/Scripts/jquery-1.11.1.min.js" type="text/javascript"></script>
<script src="/Shared%20Documents/Scripts/Script.js" type="text/javascript"></script>
  • Now Select one of the OK Button. And put the following code on it's top
<input type="button" id="btnSave" value="Save" onclick="fnSave()" />

enter image description here enter image description here Step 2: Need to populate the Script.js file - Upload jquery-1.11.1.min.js and Script.js in the Shared Documents > Scripts. Scripts is a folder that needs to be created in Shared Documents. Script.js will contain the following code

function fnSave()
{
    //TO DO: Get the Report Date input ID from View Source
var tmpReportDate = $('#ctl00_m_g_158fbd09_e200_4454_b40b_8ce5475ff4fc_ff4_1_ctl00_ctl00_DateTimeField_DateTimeFieldDate').val()
var tmpDate = new Date(tmpReportDate.split('/')[2],tmpReportDate.split('/')[0],tmpReportDate.split('/')[1]);
//Calculate Dates
var prev1year = ((tmpDate.getMonth() - 1) = 10)
{
    //Save in the Format Of: Year-Month-Type-Action
    //Current
    tmpCurrent = tmpDate.getFullYear()+'-'+tmpDate.getMonth()+'-'+tmpprevType+'-'+tmpprevAction;

    //Prev 1 Month
    tmpPrev1 = prev1year+'-'+prev1month+'-'+tmpprevType+'-'+tmpprevAction;

    //Prev 2 Month
    tmpPrev2 = prev2year+'-'+prev2month+'-'+tmpprevType+'-'+tmpprevAction;
}
    //TO DO: Get the CurrentMonth input ID from View Source
$('#ctl00_m_g_158fbd09_e200_4454_b40b_8ce5475ff4fc_ff8_1_ctl00_ctl00_TextField').val(tmpCurrent);
    //TO DO: Get the Prev1Month input ID from View Source
$('#ctl00_m_g_158fbd09_e200_4454_b40b_8ce5475ff4fc_ff6_1_ctl00_ctl00_TextField').val(tmpPrev1);
    //TO DO: Get the Prev2Month input ID from View Source
$('#ctl00_m_g_158fbd09_e200_4454_b40b_8ce5475ff4fc_ff7_1_ctl00_ctl00_TextField').val(tmpPrev2);

    //TO DO: Get the OK Action from View Source
if (!PreSaveItem()) return false;
    WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions('ctl00$m$g_158fbd09_e200_4454_b40b_8ce5475ff4fc$savebutton2$ctl00$diidIOSaveItem', '', true, '', '', false, true));
}

enter image description here

  • Now to put the actuaul values in the TO DO tagged element, browse http://<Site URL>/Lists/ECM%20Master%20List/CustomNewForm.aspx enter image description here
  • Right Click on the page and click on the View Source enter image description here
  • Seacrh with CType and get the ID of the input CType and put it in the Script.js file. enter image description here
  • Get the ID for Report Date, Action, Risk, CurrentMonth, Prev1Month and Prev2Month, Put it in the Script.js
  • Now Search with PreSaveItem and get the function and put it in the Script.js file. But replace the quot as shown in the Script.js above. enter image description here

Step 3: Create Workflow

  • Go to SharePoint Desgner and Open the Site.

  • Click File > New > Workflow enter image description here

  • Name the workflow and select the list as ECM Master List. Check the check boxes as shown below enter image description here

  • Click Next button

  • Click on the 'Varaibles..' and add the following two variables enter image description here

  • Click on the OK Button

  • Click Action > Set Workflow Variable enter image description here

  • Set tmpPrev1ID to as shown below. I am setting the ID of that list item which's CurrentMonth is equal to tmpPrev1ID. If item is not available it will save 0 in the tmpPrev1ID. enter image description here enter image description here

  • Set tmpPrev2ID to as shown below.I am setting the ID of that list item which's CurrentMonth is equal to tmpPrev2ID. If item is not available it will save 0 in the tmpPrev2ID. enter image description here

  • It will looks as follows: enter image description here

  • Now add another step
    enter image description here

  • Now add a condition as follows:
    if tmpPrev1ID Not Equals o and if tmpPrev1ID Not Equals o enter image description here

  • And in the Action create the item in your list. enter image description here

Test: Go to http://<Site URL>/Lists/ECM%20Master%20List/CustomNewForm.aspx and create the items as follows: enter image description here enter image description here

Good Luck!!!

2
  • awesome thanks. Atleast now I can base it on this now. – user60887 Jul 27 '14 at 19:10
  • 1
    It's a really nice challenging requirement. It's my pleasure of having this kind of challenge. Thanks to you. 😊 – Sudip Ranjan Sil Jul 27 '14 at 19:21

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.