Automating reassigning tasks to another user in Nintex Workflow - nintex-workflow

We have a requirement of reassigning all pending tasks of a user1 to another user2 when the user1 is away. We are maintaining a list wherein the status of users can be set.
Suppose if the User1's status is Away then all the tasks assigned to User1 should be reassigned to User2 and all this process should be done in Nintex Workflow itself ?
Please suggest on how this can be achieved?

First of all, you will need another column in your list to set the user that will receive the reassigned tasks.
Next, you have to create a new workflow associated to this list, and go to "Workflow Settings" to set "Start when items are updated" to Yes.
Finally, in your workflow you will have as current item the user who was updated (ensure that user status was changed to "Away"). Then, you just have to get the value of column you've created on first step and all tasks of current user, and assign them to the new user.
I hope it helps! ;)

Related

How to check if no new opportunity has been created in past 1 year for an account in salesforce?

I've to create an automation process to check that no new opportunities has been created for an account in past 12 months and update the account field based on that.
Tried process builder, but it doesn't seem to work.
Tricky
A flow/workflow/process builder needs some triggering condition to fire. If an account was created 5 years ago, not updated since, haven't had any opportunities - it will not trigger any flows until somebody touches it.
And even if you somehow to manage to make a time-based workflow for example (to enqueue making a Task 1 year from now if there are no Opps by then) - it'll "queue" actions only from the moment it was created, it will not retroactively tag old unused accounts.
The time-based actions suck a bit. Say you made it work, it enqueued some future tasks/field updates/whatevers. Then you realise you need to exclude Accounts of certain record type from it. You need to deactivate the workflow/flow to do it - and deactivation wipes the enqueued actions out. So you'd need to save your changes and somehow "touch" all accounts again so they're checked again.
Does it have to be a field on Account? Can it be just a report (which you could make a reporting snapshot of if needed)? You could embed a report on account layout right? A query? Worst case some apex nightly job that runs and tags the accounts? It would dutifully run through them all and set/clear your helper field, easy to change (well, for a developer).
SELECT Id, Name
FROM Account
WHERE Id NOT IN (SELECT AccountId FROM Opportunity WHERE CreatedDate = LAST_N_DAYS:365)
Reporting way would be "cross filter": https://salesforce.vidyard.com/watch/aQ6RWvyPmFNP44brnAp8tf, https://help.salesforce.com/s/articleView?id=sf.reports_cross_filters.htm&type=5

How to create task based on Case Owner in process builder?

I have some complex scenario which I am unable to achieve it. Here the below user stories I received from client.
User Story:
If the case has been in the status of 'Pending Decision' for 30 days and case owner is in queue, Task should be generated under the case. Task Owner should be assigned to 'Derrick James'. If the case has been in the status of 'Pending Decision' for 30 days and case owner is in 'Rahul Rathore' (or someone other), Task should be generated under the case. Task Owner should be assigned to 'Case Owner'.
I have done the above scenario in process builder. I am not able to assign the task owner since it has two scenario. I need to implement this configuration within a week. Please help me on this. Thanks in advance.
After digging lots of blog. Here I'm providing links which can be useful in future. Using Begins function and Using Left function

Task execution in distributed environment

I have a table say employee(id, name, email, is_email_verified, created_date). I need to send an email everyday for the users which has been created and email is not verified. I need to create a service which can be deployed on two boxes. It will read the user table and get the user id and send the mail for verification. Since, there are two boxes and each will read the same number of users and hence will send the two mails.
How, can we make this service so as user ids will get distributed among the servers (if I have n servers).
There are few ways to do that.
The most straightforward & reliable:
Create a job task that read all user ID from the table and queue them to a task queue - 1 task per user ID.
Pull task from queue using as many servers as you want (1-N).
Not requiring queues (not fault tolerant):
Choose a hash function that would decide which user IDs should server process. For example 1st server processes odd IDs and 2nd even IDs, etc. Or something like:
def should_i_send(user_id, server_id):
return user_id % server_id == 0

Conditional associated record deletion in afterDelete()

I have the following setup:
Models:
Team
Task
Change
TasksTeam
TasksTeam is a hasManyThrough, that associates teams to tasks. Change is used to record changes in the details of tasks, including when teams are attached/detached (i.e. through records in TasksTeam).
TasksTeam also cascades deletes of Task. If a task is deleted, all related team associations should also be deleted.
When a TasksTeam is deleted, it means a team has left a task, and I'd like to record a Change for that. I'm using the TasksTeam afterDelete() to record teams leaving. In the TasksTeam beforeDelete I save the data to $this->predelete so it'll be available in the afterDelete().
Here is the non-working code in TasksTeam:
public function afterDelete(){
$team_id = $this->predelete['TasksTeam']['team_id'];
$task_role_id = $this->predelete['TasksTeam']['task_role_id'];
$task_id = $this->predelete['TasksTeam']['task_id'];
// Wanted: only record a change if the task isn't deleted
if($this->Task->exists($task_id)){
$this->Task->Change->removeTeamFromTask($task_id, $team_id, $task_role_id);
}
return true;
}
Problem:
When a task is deleted, the delete cascades to TasksTeam correctly. However, a change will be recorded even if the Task is deleted. From another answer to something similar on SO, I think the reason is that the callbacks are called before Model:del(), meaning the task hasn't yet been deleted when it hits TasksTeam afterDelete()
Question
How can I successfully save a Change only if the task isn't deleted?
Thanks in advance.
If the callbacks are getting called before the actual delete, I see maintaining an assoc. array of flags with task IDs as keys, or a set of task IDs, which are added when afterDelete is called on Task. Then you could create a method in Task, such as isDeleting or similar, which queries the array, to tell you if the task is in the process of being deleted.
Using the suggestion from #James Dunne I ended up adding a tinyint field to the Task model called is_deleted and simply set this boolean true in the Task beforeDelete(). I then check for this flag and only save a Change if the flag is boolean false. It seems wasteful to add a field for something that is only affected just before the record is deleted, but for my purposes it works fine. I think a "real solution" would involve the Cake Events System , avoiding the need for chained callbacks.

Return value for correct session?

I'm working on a project in dead ASP (I know :( )
Anyway it is working with a kdb+ database which is major overkill but not my call. Therefore to do inserts etc we're having to write special functions so they can be handled.
Anyway we've hit a theoretical problem and I'm a bit unsure how it should be dealt with in this case.
So basically you register a company, when you submit validation will occur and the page will be processed, inserting new values to the appropriate tables. Now at this stage I want to pull ID's from the tables and use them in the session for further registration screens. The user will never add a specific ID of course so it needs to be pulled from the database.
But how can this be done? I'm particularly concerned with 2 user's simultaneously registering, how can I ensure the correct ID is passed back to the correct session?
Thank you for any help you can provide.
Instead of having the ID set at the point of insert, is it possible for you to "grab" an ID value before hand, and then use that value throughout the process?
So:
Start the registration.
System connects to the database, creates an ID (perhaps from an ID table) and Stores in ASP Session.
Company registers.
You validate and insert data into DB (including the ID session)
The things you put in the Session(...) collection is only visible to that session (i.e. the session is used only by the browser windows on one computer). The session is identified by a GUID value that is stored in a cookie on the client machine. It is "safe" to store your IDs there (other users won't be able to read them easily) .
either your id can include date and time - so it will be example - id31032012200312 - but if you still think that 2 people can register at the same type then I would use recordset locks liek the ones here - http://www.w3schools.com/ado/prop_rs_locktype.asp
To crea ids like above in asp you do - replace(date(),"/","") ' and then same with time with ":"
Thanks

Resources