How to Create Flows for these conditions? - salesforce

Flow Task
Create below three User Lookup fields Account-
Assigned Attorney
Assigned Paralegal
Managing Attorney
When an event is created, automatically add each of the users in these specific “fields” on an account as an attendee to each event at the point the event is created;
Assigned Attorney
Assigned Paralegal
Managing Attorney
For all future events on an Account calendar, when an assignment in one of the three fields below changes, automatically update the attendees on the event, removing any removed attendees and adding any added attendees.
Assigned Attorney
Assigned Paralegal
Managing Attorney
Recently I learned flows in salesforce and i tried this problem but didn't find out that how to approach this.

Not sure how far you got with your flow, but I'll assume it was a triggered flow / autolaunched flow, and that you're aware of the eventrelation object that links invitees to events - see reference here (https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_eventattendee.htm).
So, you'd have a Flow triggered by event creation where the event is linked to an account (aka WhatId starts with '001'). This flow would retrieve the ids from the fields you described, build a list of eventrelation records and insert them.
You'd need another Flow triggered by account update where one or more of those fields change. You'll need to check each for a change and if changed, remove the old matching eventrelation record and create a new one to reflect the new invitee.
That should cover it. Give it a shot.

Related

REDCap auto populate from previous forms

Hi I am using REDCap for data collection. My question is how to auto populate variable from one from to another form in REDCap. For example, BMI from enrollment to baseline visit.
Exactly how the piping will work will depend on your project design and setup. From your question it sounds as though you're running a longitudinal study. In a longitudinal study, an instrument exists within an event. You need to prepend the field variable name with the event name.
Say you had two events: Enrollment and Baseline, and in Enrollment you had two instruments: Consent and Medical History Questionnaire. In the Baseline event, you might have the Medical History Questionnaire again, plus event-specific forms, like a mood scale.
In REDCap, fields are globally unique among all instruments, and so usually you need to simply indicate the field using the [var] syntax. In a longitudinal study however, a single instrument can exist in multiple events, and to correctly identify the field, you need to first indicate the event name.
To pipe the BMI field (assuming it's labelled [bmi]) from the Enrollment event, you would use the piping code [enrollment][bmi].
If your instance has version 8.4 or above, you should have access to smart variables. These allow you to traverse the events in a dynamic way using variables like [previous-event], [first-event], etc. You can use this to perform advanced branching logic to display some text on a form only if that form is not in the first event of a longitudinal study: [event-name] != [first-event-name]
It's called piping in REDCap. you simply put the variable inside brackets and use it as a parameter on any forms.
This link has the piping example in it.
http://www.ecu.edu/cs-itcs/redcap/upload/REDCap-Advanced-User-Guide.pdf

How to change Work Item Approval status on Deliver in RTC

In our team, we try to implement Code Review using RTC.
Server is already configured to accept delivery of changes only when Work Item is approved.
The big issue with this approach is that once the WI is approved, it allows further multiple changesets being delivered without Reviewing them.
My question is: Can RTC be configured in such way that each delivery of ChangeSet changes the Approval Status of related Work Item to 'Pending'?
Or (worse case) delete whole approval from WI?
The big issue with this approach is that once the WI is approved, it allows further multiple changesets being delivered without Reviewing them.
One of the operation pre-conditions (the Source Control / Deliver Server one) does state:
Note: To prevent users from linking new change sets to work items that already have approvals, enable the Prevent Linking to Approved Work Items precondition.
So once approved, no more change sets should be linked to that WI. If the approval means the code has been reviewed, the WI can be delivered (knowing the number of change sets hasn't changed).
Farhan adds in the comments:
It can also be achieved by adding new approval cycle each time change-set submitted, So using this approach workItem will not be approved until all approvals gets approved.
You would need to develop extension for it, code in this article can help you to programmatically create/modify approvals: see "Creating, customizing, and deleting approval records programmatically with Rational Team Concert".

Salesforce Trigger workflow on record delete

I want to listen change in my legacy system whenever there is any change in SF object (add/update/delete). So I have created outbound message and workflow. But in workflow I don't see any way to fire if object is deleted.
Is there anyway I can trigger outbound message on record delete? I know have heard that it can be done by trigger. But I don't want to write apex code for this.
To the best of my knowledge it cannot be done, the workflow actions are decoupled from the workflow rule (you can even reuse them) so they probably do not receive the transaction scope and when they execute the record is already gone and any reference inside action would point to a non-existing data. Thus the only way I know how to do it is via trigger.
Here is a workaround. However this will only be able to capture deletion made via std. Salesforce UI.
1.Create a custom checkbox field "Is Deleted"
2.Override the Del link with a custom VF page, that first updates the record status to "Is Deleted", and deletes the record.
3.Write workflow rule using the "Is Deleted" field.
Perhaps a compromise architecture would be to write an extremely small and simple after delete trigger that simply copies the deleted records in question to some new custom object. That new custom object fires your workflow rule and thus sends the outbound message you're looking for. The only issue with this would be to periodically clean up your custom object data that would grow in size as you deleted records from your other object. In other words, your "scratch" object would just need periodic cleaning - which could be done on a nightly schedule with batch Apex.
Here's a delete trigger that would do the trick using Opportunity as an example:
trigger AfterDelete on Opportunity (after delete)
{
List<CustObj__c> co = new List<CustObj__c>();
for(Opportunity o : Trigger.old)
{
CustObj__c c = new CustObj__c();
c.Name = o.Name;
c.Amount__c = o.Amount;
c.CloseDate__c = o.CloseDate;
c.Description__c = o.Description;
// etc.
co.add(c);
}
insert co;
}
It's not ideal but at least this would save you from having to code your own trigger-based outbound messages. These can only be done using the #Future annotation, btw, since callouts directly from triggers are forbidden. Hope that helps.
write a single email send in the trigger delete event. You have it in less than 1 hour.

CakePHP afterSave Timing

I have a situation where, in a model's afterSave callback, I'm trying to access data from a distant association (it's a legacy data model with a very wonky association linkage). What I'm finding is that within the callback I can execute a find call on the model, but if I exit right then, the record is never inserted into the database. The lack of a record means that I can't execute a find on the related model using data that was just inserted into the current.
I haven't found any mention of when data is actually committed with respect to when the afterSave callback is engaged. I'm working with legacy code, but I see no indication that we're specifically engaging transactions, so I'm trying to figure out what my options might be.
Thanks.
UPDATE
The gist of the scenario is this: We're taking event registrations, but folks can be wait listed. A user can register (or be registered) for a given Date. After a registration is complete, I need to check the wait list for the existence of a record for the registering user (WaitList.user_id) on the date being registered for (WaitList.date_id). If such a record exists, it can be deleted because it's become an active registration.
The legacy schema puts me in a place where the registration isn't directly tied to a date so I can't get the Date.id easily. Instead, Registration->Registrant->Ticket->Date. Unintuitive, I know, but it is what it is for now. Even better (sarcasm included), we have a view named attendees that rolls all of this info up and from which I would be able to use the newly created Registration->id to return Attendee.date_id. Since the record doesn't exist, it's not available in the view.
Hopefully that provides a little more context.
What's the purpose of the find query inside of your afterSave?
Update
Is it at all possible to properly associate the records? Or are we talking about way too much refactoring for it to be worth it? You could move the check to the controller if it's not possible to modify the associations between the records.
Something like (in psuedo code)
if (save->isSuccessful) {
if (onWaitList) {
// delete record
}
}
It's not best practice, but it will get you around your issue.

Retrieving common data on different forms

Lets take an example of WinForms applcation and making invoice. On the Invoice form we retrieve a list of products, so the user will be ale to pick products for current invoice. Lets also consider that during this process user realizes that he needs to add a new product (or edit current) to ProductList before he can place it in invoice. So he opens a ProductForm where all the products are retreived (again).
It could also be in opposite order, that user first edits Products, and then without closing the Products Form, opens new Invoice. The principle is that data is two times loaded, and effectively its the same data.
What is the propper way to handle this scenario, so we can tell one form that data is already loaded, and to retrieve that data from memory? And when all the consumers (Forms) of the data are closed, then also the data should be released from memory? Or I am going in wrong direction, and there is a better way?
Thanks,
Goran
Definitelly go with data loaded "twice" or you will introduce much worse problems.
Sharing data means sharing ObjectContext. Even in WinForms application this is considered as bad approach. Check this article (it is about NHibernate but the description is valid for EF as well).
The problem is that ObjectContext is unit of work. If share context between two windows you can easily get into situation where you modify data in first window (without saving them!) and you continue in second window where you push save button but it will save data from both windows! You can't selectively save data only from one window when you share the context.
If the Controls that are using the data are all child controls of a shared Parent control, then you could just pass around the datacontext, so that they all shared the same datacontext.
However, the general use case with databases, which is what backs EF in most cases, is to read the data in each time that it is needed.
A solution to this if as you say you already have the item being used in one form is to just take a Refrence to that item into your new form.
So in the case Where you have an invoice which has a Product List and you want to add to the product list, you could pass the product list from the invoice to the opening product list.
There are some issues with this:
If another user changes the datasource while one has opened it (a.k.a. Concurrency)
Handling save don't save scenarios where they may have made a change in one area that they don't actually want added to the data.
However, unless it is a true performance issues, I would just load the data every time. You can simplify this a lot by using the repository pattern, so you can just call a single method to get a list of products or an invoice, or whatever part of data you need.

Resources