Daily Routine Workflow in Orchard 1.7 - orchardcms

I need to create a workflow that runs a daily routine.
Is this possible?
If, so. How will it fire?
The workflow will only have to delete some content from the DB when their 'expiry date' has passed.
Could do in code, but think everyone will benefit from it.
Ta

Check my module: https://ambaworkflow.codeplex.com/SourceControl/latest
It contains Periodical Event.
It is alfa, but it works...
For deleting expired content you can create your own activity, like this: https://ambaworkflow.codeplex.com/SourceControl/latest#Activities/WriteEventLogActivity.cs

Related

NetSuite, Assembly Build: how do I force a client script to detect the AB's creation?

So I have a script that runs on create of Assembly Builds. It works perfectly when creating the AB manually but when the Assembly Build is created from a PO and then an IR I get an issue. It seems that because the transaction is generated automatically by NetSuite it does NOT trigger my User Event scripts afterSubmit function and then the development does not run.
Any ideas on how to force it to trigger the UE?
Netsuite has a hard limitation that one UserEvent script cant trigger another UserEvent script. (maybe their worst idea ever, but it's a thing)I'm guessing that the PO is generating the AB in its UserEvent script, and that is why the AB's userEvent script is not firing.
To get around this, you could write a scheduled script that processes any new AB's (maybe add a field that gets set when it is processed), then in the P.O. and any other relevant records afterSubmit events, you could tigger the scheduled script to handle any new assembly builds.
However you choose to solve it, you will likely have to do it in the afterSubmit events of the PO IR records.
adding on to simons comment on the user event deployment under the context filtering you need to choose the execution context like user interface , user event script , csv import to let your script only execute on the following occasions

'When an item is created or modified' trigger not firing until manually saved

I'm running into an odd issue where my Flow will not trigger correctly upon modifying a list item. I have flow set up to copy appended Col1 content to Col2 which can then be listed as an 'updated comment' in my list's default view.
It's the same logic as a SP2013 workflow I've been using, but for whatever reason the flow will not automatically trigger when an item is created/modified in my list - it will only trigger if I go back into the flow and manually save it (the Flow) again. Additionally, if I manually save the Flow a second time, it wipes Col2's existing content.
I am not intimately familiar with any quirks found in the 'When an item is created or modified' SharePoint trigger in Flow, but it's possible I'm missing something obvious.
Below is the logic I'm using.
'Comment Update' MS Flow example
Any help would be much appreciated, I haven't been able to find any posts going over this Flow trigger specifically. It seems like there would either be a very obvious solution to this, or this is a glaring bug with Flow.
Thank you for your time.

CRM 2011 Workflow not triggered before mandatory fields are checked

I am looking to create a workflow that will populate any mandatory fields that do not contain data when a company is deactivated. The mandatory fields are either not populated because of legacy data or because the mandatory fields have changed since the record was created.
The issue I get is that the mandatory field check takes place before the workflow is triggered.
My workflow looks like follows:
If Status = Inactive
If Company Name does not contain data
Then update to ‘Test’
I have come up with a possible solution:
• Create a new button in the ribbon that runs the workflow on-demand and apply permissions to this button.
If possible though I would like to do this through a workflow that is triggered on clicking of the ‘Deactivate’ button. Any ideas are welcome.
In your situation the record will not be saved until the mandatory fields are filled, and a workflow cannot be triggered if a record is not saved first.
An approach to solve this situation is to write a JavaScript attached to the OnSave event, but you need a rule to be able to identify the legacy records, so this JavaScript (that will fill the mandatory fields for you) will not run for normal records.
This approach is not tested, but with some tweaks should work.

Deleting a record in javascript

I need to delete some records related to the current record when it is deactivated. I can get the the event when the record is deactivated but I have looked around for some time on Google and this site for the code to delete records in javascript but I can't find any, though I know there must be some out there.
Can anyone help?
Thanks
I would be alright with doing this with a plugin, all I would need to know is how to pick up that the record has been deactivated
You can register a plugin on the SetState and SetStateDynamic messages (recommend the Pre event in your scenario). Each of these messages will pass an EntityMoniker in the InputParameters property bag which refers to the record that is being deactivated.
In your code you will need to:
Check that the new state in the SetState request is deactivated (since of course a record can usually be reactivated and you don't want to try deleting things then too, presumably)
Pick up the EntityMoniker from IPluginExecutionContext.InputParameters
Run your query to identify and delete related records
Exit the plugin to allow the SetState transaction to complete
If you really want to delete a record with JavaScript there is a sample on the MSDN.
Its a little long winded (its a CRUD example - create, retrieve, update & delete). But it should contain the information you need.
Note there is also an example on that page which doesnt use jQuery (if using jQuery is a problem).
That said I think for this operation would will find it easier to implement, test and maintain with a plugin (so I would go for Greg's answer).
Additionally a plugin will apply in all contexts, e.g. if you deactivate the record in a workflow your JavaScript will not run, but a plugin will.

Automatically copy list data from one list to another list after 1 month

I have list that having data stores dynamically once the infopath form has been submitted. I want to archive this data after 30 days of creation date of any data. can you please suggest how would i do this. see i can do this by workflow but how can i set the condition that once 30 days complete after creation of any list it will automatically copy into other list.
First I would want to question WHY you want to move it to another list?
Why not simply setup a view on your main list showing only records created in last 30 days :-
Created >= [Today]-30
(And yes, you can use Today in view filters)
The best way to proceed is to create a timer job and define the criteria (like when should it be running) while creating the job. We have a very helpful post by SharePoint MVP here on how to create custom jobs. Note, you can test the job and business logic for shorter duration and if it works fine, you can simply extend the job duration for 30 days.
Its very simple, all you have to do is to define your 'copying list' logic in the Execute method of job class.
Good luck
I believe you can simply use standard out-of-the-box workflow activities to do this - no need for timer jobs or console apps.
Using SharePoint Designer, create a new workflow (New -> SP Content -> Workflow). Specify the list to attach the workflow to.
Specify that the workflow should start on item creation only.
In the first Step, add an action: Pause for duration. Make the duration 30 days.
Add another action: Copy list item. Specify the list to copy to.
Optionally: create a third action: Delete list item if you want the original item to be deleted from the original list.
And I think that's it :)
you have to crate a timer job which runs daily and move the items which are one month old
Potentially the easiest solution is to create a console application that you schedule to run on the SharePoint server (an alternative to creating a timer job).
Depending on how you want to archive the data, you could:
Get the list items (probably using GetItems), save them to a file or a DB, and delete the old items
Use custom STSADM commands to export the list (backup just the list)
Backup the entire site using STSADM
There's a limit on number of items in a list of 5000 items and if you change this in administration you'll kill performance. There are perfectly valid reasons to want to archive old items off of a rapidly growing list. exceeds the list view threshold 5000 items in Sharepoint 2010

Resources