Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

If Territory_vod__c is supplied on Insert, don't run auto align #4

Open
stephenbrown1 opened this issue Sep 19, 2014 · 0 comments
Open

Comments

@stephenbrown1
Copy link
Owner

As per email from Jesse:
Hey Kids, found a "snag", and a workaround, but want to throw it in Steven and Wayne's court, to see what their thoughts are.

Background:

Spectrum uses ZipTerr for alignment.

Spectrum reps can create non-licensed professionals, but cannot create licensed professionals or orgs. The latter is managed via their data master, which was created by Cognizant.

Spectrum receives a daily flat file (.csv) for new HCPs, Orgs, and Addresses. Current process is that each day their SFDC admin receives these files, she uploads them using apex data loader. We found that on INSERT of a net new record, if you populate Territory_vod__c, the accounts auto-align. This happened before Stephen's awesome code, which does the same thing for new new accounts entered via the UI.

Post Stephen Code:

We found that Stephen's code worked splendidly for users who entered net new non-licensed profs into Veeva. However, we discovered the daily dataload process had broken. The accounts loaded, but were no longer aligned. I believe there were 2 factors:

  1. The apex data load process was not a "batch" process
  2. The territory_vod__c process was not null

The only way I was able to get the data load auto-align process working, and keep the auto-align also working for net new non-licensed professionals (via UI) was to have the user turn on the "batch" setting in the Apex Data loader (i.e. use bulk api).

Interesting - think the reasons for this would be:

  • via apex data loader (batch mode or otherwise) the std 'run active assignment rules for this account' would trigger on net new load. If territory_vod__c was populated then this means the Veeva terr code is overridden, and the SFDC terr rules will run. No problem with this.
  • posibly the issue when putting in the veeva-terr code, is that for net new, there is a conflict - the territory_vod__c is populated, but the auto align code would also run, and would run the veeva alignment, and becuase there would not yet be an address, the Veeva alignment would result in a null territory_vod__c, so would override the loaded value.
  • interesting that using bulk mode means this does in fact work - prob because the veeva-terr code looks for batch mode, and doesn't execute if batch mode is used

This isn't foolproof (ie relies on user setting this option), so my suggestion would be to tweak the veeva-terr code, and not execute :
if (trigger.isInsert() && trigger.new[i].Territory_vod__c != null)

ie. if it's a brand new record, and the territory_vod__c is populated, then use that value, don't try and re-align the record.

Then this doesn't rely on batch mode or a particular method of loading the data.

Jesse, you think this would work ok?

For any integration from master data, the 'standard' veeva-terr should work fine, so long as they don't populate territory_vod__c and let Veeva sort it out... no change necessary.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant