Discussion:
Workflow to act based on existance of records
(too old to reply)
Taylor
2010-05-21 17:06:01 UTC
Permalink
I'm not sure if out of the box workflows can handle this or if we need to
build something custom but basically I have the contact entity and a custom
Subscription entity linked via a 1:N relationship (each contact can be
subscribed to multiple subscription records). Each subscription record is
identified by type, which is a drop down of 5 various subscriptions as well
as the person who subscribed them. Therefore a person may have 2+
subscription records for the same subscription but different people are
subscribing them.

What I want to do is have summary fields on the contact record iteself for
each of the 5 subscriptions. So if they have ANY subscription to
subscription A then I want a checkbox on the contact to be marked "yes". If
those subscriptions are deleted I want to mark that box as "no" but only if
ALL subscriptions of that type have been deleted.

The adding part is easy. Whenever a subscription of whatever type is added,
mark the box on the contact for the corresponding type. But the delete is
where I'm having trouble. Can the workflow check to see if other record
exist of the same type instead of just the current record? I thought maybe
using child workflows perhaps.

Any ideas are welcome.
AdamV
2010-05-22 21:41:52 UTC
Permalink
Short answer: no, you can't do this as you describe it in workflow out
of the box.
There's no mechanism for doing a loop through all records of a certain
criteria such as all subscriptions associated with a contact.

Best workaround: actually keep a count of subs of each type rather than
a yes no. If you really want to you could hide these fields on the forms
(but you need to add them to the form in the first place to be able to
get at them in the workflow editing GUI).
Then you could increment the number depending on subs being added and
set the bit field to "yes", or decrement based on cancellations of subs
and check if it reached 0 (check for <1, not =0, see below) and set it
to "no", and set the value to =0.

if you have a really busy environment and lots of workflows running, the
asynch service may take a while to process these jobs and it is possible
there could be timing issues between adding and removing subs.

Hope this alternative approach helps.

Adam
Post by Taylor
I'm not sure if out of the box workflows can handle this or if we need to
build something custom but basically I have the contact entity and a custom
Subscription entity linked via a 1:N relationship (each contact can be
subscribed to multiple subscription records). Each subscription record is
identified by type, which is a drop down of 5 various subscriptions as well
as the person who subscribed them. Therefore a person may have 2+
subscription records for the same subscription but different people are
subscribing them.
What I want to do is have summary fields on the contact record iteself for
each of the 5 subscriptions. So if they have ANY subscription to
subscription A then I want a checkbox on the contact to be marked "yes". If
those subscriptions are deleted I want to mark that box as "no" but only if
ALL subscriptions of that type have been deleted.
The adding part is easy. Whenever a subscription of whatever type is added,
mark the box on the contact for the corresponding type. But the delete is
where I'm having trouble. Can the workflow check to see if other record
exist of the same type instead of just the current record? I thought maybe
using child workflows perhaps.
Any ideas are welcome.
Dave
2010-05-23 16:50:48 UTC
Permalink
Post by Taylor
I'm not sure if out of the box workflows can handle this or if we need to
build something custom but basically I have the contact entity and a custom
Subscription entity linked via a 1:N relationship (each contact can be
subscribed to multiple subscription records).  Each subscription record is
identified by type, which is a drop down of 5 various subscriptions as well
as the person who subscribed them.  Therefore a person may have 2+
subscription records for the same subscription but different people are
subscribing them.
What I want to do is have summary fields on the contact record iteself for
each of the 5 subscriptions.  So if they have ANY subscription to
subscription A then I want a checkbox on the contact to be marked "yes".  If
those subscriptions are deleted I want to mark that box as "no" but only if
ALL subscriptions of that type have been deleted.
The adding part is easy.  Whenever a subscription of whatever type is added,
mark the box on the contact for the corresponding type.  But the delete is
where I'm having trouble.  Can the workflow check to see if other record
exist of the same type instead of just the current record?   I thought maybe
using child workflows perhaps.  
Any ideas are welcome.  
Taylor,
You're best bet is to use onSave Javascript or write a plug-in. Then
you can loop through all child records to derive your checkboxes.
HTH,
Dave

-------------------------------------------
David L. Carr, President
Visionary Software Consulting, Inc.
Cell: 503-351-4207
Email: ***@earthlink.net
http://www.vscrm.com
AdamV
2010-05-24 12:49:44 UTC
Permalink
OnSave javascript won't be any good if the subscription records are
deleted (especially if deleted from a grid view), or if a subscription
is moved to a different Contact (the original link is lost and so the
checkbox would not get unchecked), nor if a subscription can be created
in any way other than via a form (eg by a workflow).

A plugin might fare better but could also suffer from some similar
limitations.
Adam
Post by Dave
Post by Taylor
I'm not sure if out of the box workflows can handle this or if we need to
build something custom but basically I have the contact entity and a custom
Subscription entity linked via a 1:N relationship (each contact can be
subscribed to multiple subscription records). Each subscription record is
identified by type, which is a drop down of 5 various subscriptions as well
as the person who subscribed them. Therefore a person may have 2+
subscription records for the same subscription but different people are
subscribing them.
What I want to do is have summary fields on the contact record iteself for
each of the 5 subscriptions. So if they have ANY subscription to
subscription A then I want a checkbox on the contact to be marked "yes". If
those subscriptions are deleted I want to mark that box as "no" but only if
ALL subscriptions of that type have been deleted.
The adding part is easy. Whenever a subscription of whatever type is added,
mark the box on the contact for the corresponding type. But the delete is
where I'm having trouble. Can the workflow check to see if other record
exist of the same type instead of just the current record? I thought maybe
using child workflows perhaps.
Any ideas are welcome.
Taylor,
You're best bet is to use onSave Javascript or write a plug-in. Then
you can loop through all child records to derive your checkboxes.
HTH,
Dave
-------------------------------------------
David L. Carr, President
Visionary Software Consulting, Inc.
Cell: 503-351-4207
http://www.vscrm.com
LeonTribe
2010-06-11 14:44:00 UTC
Permalink
Post by Taylor
I'm not sure if out of the box workflows can handle this or if we need to
build something custom but basically I have the contact entity and a custom
Subscription entity linked via a 1:N relationship (each contact can be
subscribed to multiple subscription records).  Each subscription record is
identified by type, which is a drop down of 5 various subscriptions as well
as the person who subscribed them.  Therefore a person may have 2+
subscription records for the same subscription but different people are
subscribing them.
What I want to do is have summary fields on the contact record iteself for
each of the 5 subscriptions.  So if they have ANY subscription to
subscription A then I want a checkbox on the contact to be marked "yes".  If
those subscriptions are deleted I want to mark that box as "no" but only if
ALL subscriptions of that type have been deleted.
The adding part is easy.  Whenever a subscription of whatever type is added,
mark the box on the contact for the corresponding type.  But the delete is
where I'm having trouble.  Can the workflow check to see if other record
exist of the same type instead of just the current record?   I thought maybe
using child workflows perhaps.  
Any ideas are welcome.  
The only way to do this with out of the box workflows is to use the
workflow increment/decrement function. Rather than having a tickbox on
the parent record, have an int attribute. You can then check if the
attribute is 0 or greater than 0.

http://leontribe.blogspot.com/2009/02/leons-quick-and-dirty-workflow-counter.html

Leon Tribe
Want to hear me talk about all things CRM? Check out my blog
http://leontribe.blogspot.com/
or hear me tweet @leontribe

Loading...