Skip to main content

Is there a way to increment the value of a data field by 1?


I need a workflow which loops through a SharePoint list of items by the counter.


Any help appreciated.


Thanks


Dennis

This would only be easily done with 4.5 using the numeric functions in the inline function.  In the current 0902, you need to write an external function in a assembly to do this.


Thanks - so if the data field cannot be used, what can I do?


Basically I have a list of alert dates in a SharePoint list and I want to create a workflow looping through the ID fields, as shown:


ID    Alert Date


1     10 Jan 2010


2     12 Feb 2010 


3     14 Mar 2010


...


The workflow should stop when ID reaches 12. How should I do this if data field cannot increment itself?


Thanks


Dennis


 


 


Sorry perhaps my previous reply wasn't clear enough.


In 0902, you have to build a simple .NET assembly class that has a single method that increments a number.


e.g.


int AddOne(int CurrValue)


{


   return CurrValue + 1;


}


You can then reference this in your project and then call it using your reference wizard.  Pass in your data field as the input and assign back the return result to the same data field.  This will effectively increment your data field.


Now with that being said, it is now a snap in blackpoint 4.5 (currently in RC) as the new inline functions library will be able to do this out of the box. So there is no need to mess around with custom dlls.


The final RTM should be somewhere in the end Mar/early Apr timeframe (pending final testing).  Also note that the 4.5 RC will be upgradable to the RTM so you could technically build on top of the 4.5 RC now and later upgrade.  RC files are currently availabel via the K2 portal beta downloads (make a request to your local rep if you don't have access).


Thanks for your response Johnny, but I am still pretty stuck here. Let me describe the problem in more details:


Basically I have a list called report schedule which is like this:


Month    Year             Alert Date for Period


1             2010                 21 Jan 2010


2             2010                22 Feb 2010


...


12          2011                 20 Dec 2011


So it will be around 24 entries.


When a certain action is triggered (in this case a list item has been created), I need to get the current date so that the correct alert date can be chosen. For example, when a user does something on 1 Jan 2010, it should trigger the K2 workflow to choose the 21 Jan 2010 alert date. (However, if this is not supported, I can live with users entering the month and year value in order to retrieve the alert date).


Once the alert date is obtained, I will put that into another list called current report date just to keep it. The timer workflow will then wait until the date (in this example, 21 Jan 2010) and send an alert to users. Once that is completed, the next item in the report schedule (i.e. 22 Feb 2010) should be updated to this current report date list.


In K2, I could create the timer alert no problem, but my main struggles were:


1) How do I assign the current SharePoint list row (ID) in Report Schedule to a data field (based on the current month and year)?


2) How do I increment tat data field so that the timer workflow can tun continuously untl it reaches the last entry?


I understand K2 blackpoint may be not built for this type of workflow - but I am not really a programmer so do not really how to write custom assembly (and I thought datafield would do the job). But if it is necessary, please let me know how and I will try to wotk this out.


Many thanks


Dennis


 


 


More information about what I have tried:


I will tried assigning SmatObject.load value to a data field in the data event (trying to put the current list item ID to a numeric data field), but it throws an error and says the source datafield <Data Field Name> is not initialised or does not exist.


I have also tried incrementing a data field by itself using the data event (e.g. source = <Data Field Name> + 1 and destination = <Data Field Name> but it doesn't work.


Last but not least I have tried creating a numeric field in a SharePoint list (since data field does not really work) and try to increment it through the update list item event but seems like the data type doesn't match.


Many thanks


Dennis


I am not too certain why you are getting the first error (maybe a screenshot of your settings might tell more).


Also note the data event wizard does mappings and does not allow you to execute mathematical functions (hence the reason for inline functions in 4.5). 


Just a thought here.  Given that 4.5 is currently in RC and upgradable to RTM (which is not too far off).  Would it make sense to try doing this on 4.5 RC and then upgrade this later to RTM?  I would think that you would get a much better experience in building your process with the availability of inline functions.


 


Reply