You need to sign in to do that
Don't have an account?
sudhirn@merunetworks.com
Suggestion on writing the logic for test class on entitlement
Hi,
Need a suggestion for writing a test class for below trigger logic is it updates entitlement when opportunity NS Start and NS End Dates are updated in opportunity product
Thanks
Sudhir
Need a suggestion for writing a test class for below trigger logic is it updates entitlement when opportunity NS Start and NS End Dates are updated in opportunity product
trigger update_entitlement on Opportunity (after insert, after update) { set<id> oppid = new set<id>(); for( opportunity op : trigger.new) { oppid.add(op.id); } EntitlementUtil.updateentitlement(oppid); }Below is the class that is getting called inside the trigger
public with sharing class EntitlementUtil { public static void updateentitlement(set<ID> opp){ list<entitlement> ent = [select Opportunity__c,StartDate,EndDate from Entitlement where Opportunity__c in :opp]; opportunity getopp = [select NS_Start_Date_Min__c,NS_End_Date_Max__c from opportunity where id = :opp]; for( entitlement gent : ent) { gent.StartDate = getopp.NS_Start_Date_Min__c; gent.EndDate = getopp.NS_End_Date_Max__c; update gent; } } }Please suggest me how should i be writing the logic to update the dates.
Thanks
Sudhir
first of all (sorry that I'm pointing it out) your code is very messy.
I'm not sure how it should work for after insert cause it may be that there is no relatation from opportunity to entitlement yet then.
But after update is easy.
As given: Prepare one Opportnintiy and one Entitlement.
As when: Update NS_Start_Date_Min__c on Opportunity
As then: Check if StartDate in Entitlement (in DB) is udpated.
Hi Stefan,
Sorrry for the confusion logic is simple any time opportuntiy is updated it should update the entitlement start and end date from opportuninty start and end that is what in the class
Thanks
Sudhir