-
ChatterFeed
-
2Best Answers
-
0Likes Received
-
0Likes Given
-
3Questions
-
9Replies
Time-off manager to manage sick leave
I'm investaging time-off manager package to manage PTO requests for my organization. I have installed it to my sandbox and created some dummy information. Annual leave and paid time off work perfectly, the time-off balance is adjusted automatically, but I dont know how to create sick leave which shouldnt deduct the accrued time-off.
Does anyone have the experience of using this package in your organization? How do you manage sick-leave? Or is this package doesnt have the ability to manage sick-leaves?
Thank for your help in advance.
Yosef
-
- kapalselam
- August 26, 2008
- Like
- 0
- Continue reading or reply
Automatically Approving
Hello,
I have what I thought would be a simple requirement, namely to automatically approve a record if the assigned approver is a specific user. Unfortunately, the Approval object does not allow for triggers, and I can't find any sample code anywhere to go off of.
Thanks,
Geoffrey
-
- Geof131313
- February 21, 2012
- Like
- 0
- Continue reading or reply
Batching Submit For Approval From Triggers
Hello,
I wrote a generic trigger that submits an Opportunity for approval when a picklist meets the appropriate criteria. The purpose is to allow us to submit using a workflow rule/upload etc.
Code is here:
trigger SubmitFromTrigger on Opportunity (after insert, after update) {
list<Opportunity> updateOpps = new list<Opportunity>();
for(Opportunity opp : trigger.new){
if( opp.submit_from_trigger__c == 'Yes'){
Opportunity placeHolderOpp = new Opportunity(id = opp.id, submit_from_trigger__c = 'No');
updateOpps.add(placeHolderOpp);
approval.ProcessSubmitRequest req1 = new Approval.ProcessSubmitRequest();
req1.setObjectId(opp.id);
approval.ProcessResult result = Approval.process(req1);
}
}
Update updateOpps;
}
This script works as it is supposed to. The only problem is that I could not figure out how to batch the submit for approval command, so when I ran a test in our sandbox submitting 23 at a time it worked, but when I did it using 102 it did not.
So I guess my questions are 1) Is it possible to batch the approval submit command, 2) If so, how?, and 3) If not, can we change that in an upcoming release?
Thanks,
Geoffrey
-
- Geof131313
- February 18, 2011
- Like
- 0
- Continue reading or reply
Issue with test class not validating properly
Hello,
I am having an issue with a test class that I can't for the life of me figure out why it won't validate my code properly.
The Trigger does the following:
- Runs on Campaign Member create/update
- If campaign member contains LeadId, push Campaign.CampaignName into Lead.Campaign_Name__c, a custom text field on the Lead object
- If campaign member contains LeadId and associated Lead.Campaign_Name__c is not null (before insert), set Email_Inside_Sales_Rep__c to 1
- If campaign member contains ContactId, set Account.Email_AM__c to 1
- If campaign member contains ContactId and Account.AccountManager__c <> Account.Customer_Relationship_Manager__c, set Email_CRM__c to 1
public class CampaignPushTest {
static testMethod void runCampPushTest() {
Lead lead1 = new Lead();
lead1.firstname = 'test';
lead1.lastname = 'insert';
lead1.company = 'ReturnPathTest';
insert lead1;
Lead lead2 = new Lead();
lead2.firstname = 'test2';
lead2.lastname = 'insert2';
lead2.company = 'ReturnPathTest2';
lead2.campaign_name__c = 'SSORG: Test';
lead2.Email_Inside_Sales_Rep__c = 0;
insert lead2;
Campaign cmpn1 = new Campaign();
cmpn1.name = 'TestInsert';
cmpn1.IsActive = true;
insert cmpn1;
Campaign cmpn2 = new Campaign();
cmpn2.name = 'TestInsert2';
cmpn2.IsActive = true;
insert cmpn2;
Campaign cmpn3 = new Campaign();
cmpn3.name = 'TestInsert3';
cmpn3.IsActive = true;
insert cmpn3;
Account acct = new Account();
acct.name = 'RPTestAcct';
acct.AccountManager__c = 'Unassigned';
acct.Email_AM__c = 0;
acct.Email_CRM__c = 0;
acct.Customer_Relationship_Manager_Primary__c = 'Unassigned';
insert acct;
Contact contct = new Contact();
contct.lastname = 'test2';
contct.accountid = acct.id;
insert contct;
//Run as Sales Ops
User SalesOps = new User(id = '00500000006olmF');
System.RunAs(SalesOps){
CampaignMember CmpnM1 = new CampaignMember();
CmpnM1.leadid = lead1.id;
CmpnM1.campaignid = cmpn1.id;
insert CmpnM1;
}
integer theNewLead = [select count() from Lead where Campaign_Name__c = 'TestInsert' limit 1];
if(theNewLead > 0){
System.Assert(true);
}
else{
System.Assert(false);
}
System.RunAs(SalesOps){
CampaignMember CmpnM2 = new CampaignMember();
CmpnM2.leadid = lead2.id;
CmpnM2.campaignid = cmpn1.id;
insert CmpnM2;
}
integer theNewLead2 = [select count() from Lead where Email_Inside_Sales_Rep__c > 0 limit 1];
if(theNewLead2 > 0){
System.Assert(true);
}
else{
System.Assert(false);
}
System.RunAs(SalesOps){
CampaignMember CmpnM3 = new CampaignMember();
CmpnM3.contactid = contct.id;
CmpnM3.campaignid = cmpn1.id;
insert CmpnM3;
}
integer theNewAcct = [select count() from Account where Email_CRM__c > 0 limit 1];
if(theNewAcct == 0){
System.Assert(true);
}
else{
System.Assert(false);
}
acct.AccountManager__c = 'testAM';
acct.Email_CRM__c = 0;
update acct;
System.RunAs(SalesOps){
CampaignMember CmpnM4 = new CampaignMember();
CmpnM4.contactid = contct.id;
CmpnM4.campaignid = cmpn2.id;
insert CmpnM4;
}
integer theNewAcct2 = [select count() from Account where Email_AM__c > 0 limit 1];
if(theNewAcct2 > 0){
System.Assert(true);
}
else{
System.Assert(false);
}
acct.Customer_Relationship_Manager_Primary__c = 'testCRM';
acct.Email_AM__c = 0;
update acct;
System.RunAs(SalesOps){
CampaignMember CmpnM5 = new CampaignMember();
CmpnM5.contactid = contct.id;
CmpnM5.campaignid = cmpn3.id;
insert CmpnM5;
}
integer theNewAcct3 = [select count() from Account where Email_CRM__c > 0 limit 1];
if(theNewAcct3 > 0){
System.Assert(true);
}
else{
System.Assert(false);
}
}
}
The error that I am getting has to do with the fact that my queries are returning a count of 0, and as a result evaluating false. I can't figure out why this is, everything is working properly when I run actual sandbox tests on the objects. Can someone please help me with this?
P.S. Here's the code for the trigger and the error messages:
trigger campaign_name_push on CampaignMember (after insert, after update) {
list<CampaignMember> theCampMemb = new list<CampaignMember>();
list<CampaignMember> theCampMemb2 = new list<CampaignMember>();
list<Id> theCampaigns = new list<Id>();
list<Id> theLeads = new list<Id>();
list<Id> theContacts = new list<Id>();
list<Id> theAccounts = new list<Id>();
for(CampaignMember cpmb : trigger.new) {
if(cpmb.leadid <> null) {
theCampMemb.add(cpmb);
theCampaigns.add(cpmb.campaignid);
theLeads.add(cpmb.leadid);
}
else if(cpmb.contactid <> null){
theCampMemb2.add(cpmb);
theContacts.add(cpmb.contactid);
}
}
map<Id,Campaign> campNames = new Map<Id,Campaign>([Select Name from Campaign where Id in :theCampaigns]);
map<Id,Lead> leadNames = new Map<Id,Lead>([Select Campaign_Name__c from Lead where Id in :theLeads]);
map<Id,Contact> AcctIds = new Map<Id,Contact>([Select AccountId from Contact where Id in :theContacts]);
for(Id getaccts : theContacts){
theAccounts.add(AcctIds.get(getaccts).AccountId);
}
map<Id,Account> AcctManagers = new Map<Id,Account>([Select AccountManager__c, Customer_Relationship_Manager_Primary__c from Account where Id in :theAccounts]);
list<Lead> UpdateLeads = new list<Lead>();
list<Account> UpdateAccounts = new list<Account>();
system.debug('before cm loop');
for(CampaignMember cm : theCampMemb){
system.debug('in cm loop');
Lead l = new Lead(Id = cm.LeadId);
l.Campaign_Name__c = campNames.get(cm.CampaignId).name;
system.debug('after getting campaign_name' + l.Campaign_Name__c);
if(leadNames.get(cm.LeadId).Campaign_Name__c <> null){
l.Email_Inside_Sales_Rep__c = 1;
system.debug('after setting inside sales rep');
}
UpdateLeads.add(l);
}
for(CampaignMember cm2 : theCampMemb2){
String AM = AcctManagers.get(AcctIds.get(cm2.contactid).AccountId).AccountManager__c;
String CRM = AcctManagers.get(AcctIds.get(cm2.contactid).AccountId).Customer_Relationship_Manager_Primary__c;
Account a = new Account(Id = (AcctIds.get(cm2.contactid).AccountId));
a.Email_AM__c = 1;
if(AM <> CRM) a.Email_CRM__c = 1;
a.ContactId__c = cm2.contactid;
UpdateAccounts.add(a);
}
Update UpdateLeads;
Update UpdateAccounts;
}
Error Messages:
P.P.S. Whenever I put the code in it seems to reformat like this, so if anyone has any advice on how to fix this or would like me to send them the files, please email me.
-
- Geof131313
- November 10, 2009
- Like
- 0
- Continue reading or reply
Batching Submit For Approval From Triggers
Hello,
I wrote a generic trigger that submits an Opportunity for approval when a picklist meets the appropriate criteria. The purpose is to allow us to submit using a workflow rule/upload etc.
Code is here:
trigger SubmitFromTrigger on Opportunity (after insert, after update) {
list<Opportunity> updateOpps = new list<Opportunity>();
for(Opportunity opp : trigger.new){
if( opp.submit_from_trigger__c == 'Yes'){
Opportunity placeHolderOpp = new Opportunity(id = opp.id, submit_from_trigger__c = 'No');
updateOpps.add(placeHolderOpp);
approval.ProcessSubmitRequest req1 = new Approval.ProcessSubmitRequest();
req1.setObjectId(opp.id);
approval.ProcessResult result = Approval.process(req1);
}
}
Update updateOpps;
}
This script works as it is supposed to. The only problem is that I could not figure out how to batch the submit for approval command, so when I ran a test in our sandbox submitting 23 at a time it worked, but when I did it using 102 it did not.
So I guess my questions are 1) Is it possible to batch the approval submit command, 2) If so, how?, and 3) If not, can we change that in an upcoming release?
Thanks,
Geoffrey
- Geof131313
- February 18, 2011
- Like
- 0
- Continue reading or reply
Auto Approval is feasible?
Hi,
I have an Approval process, and I want to auto approve if 36 hours after submit for Approval, approver does not approve.
As record get locked after submit, my time dependent work not working, any other option available in SFDC.
Thanks,
Raj
- RajMania
- January 26, 2010
- Like
- 0
- Continue reading or reply
Issue with test class not validating properly
Hello,
I am having an issue with a test class that I can't for the life of me figure out why it won't validate my code properly.
The Trigger does the following:
- Runs on Campaign Member create/update
- If campaign member contains LeadId, push Campaign.CampaignName into Lead.Campaign_Name__c, a custom text field on the Lead object
- If campaign member contains LeadId and associated Lead.Campaign_Name__c is not null (before insert), set Email_Inside_Sales_Rep__c to 1
- If campaign member contains ContactId, set Account.Email_AM__c to 1
- If campaign member contains ContactId and Account.AccountManager__c <> Account.Customer_Relationship_Manager__c, set Email_CRM__c to 1
public class CampaignPushTest {
static testMethod void runCampPushTest() {
Lead lead1 = new Lead();
lead1.firstname = 'test';
lead1.lastname = 'insert';
lead1.company = 'ReturnPathTest';
insert lead1;
Lead lead2 = new Lead();
lead2.firstname = 'test2';
lead2.lastname = 'insert2';
lead2.company = 'ReturnPathTest2';
lead2.campaign_name__c = 'SSORG: Test';
lead2.Email_Inside_Sales_Rep__c = 0;
insert lead2;
Campaign cmpn1 = new Campaign();
cmpn1.name = 'TestInsert';
cmpn1.IsActive = true;
insert cmpn1;
Campaign cmpn2 = new Campaign();
cmpn2.name = 'TestInsert2';
cmpn2.IsActive = true;
insert cmpn2;
Campaign cmpn3 = new Campaign();
cmpn3.name = 'TestInsert3';
cmpn3.IsActive = true;
insert cmpn3;
Account acct = new Account();
acct.name = 'RPTestAcct';
acct.AccountManager__c = 'Unassigned';
acct.Email_AM__c = 0;
acct.Email_CRM__c = 0;
acct.Customer_Relationship_Manager_Primary__c = 'Unassigned';
insert acct;
Contact contct = new Contact();
contct.lastname = 'test2';
contct.accountid = acct.id;
insert contct;
//Run as Sales Ops
User SalesOps = new User(id = '00500000006olmF');
System.RunAs(SalesOps){
CampaignMember CmpnM1 = new CampaignMember();
CmpnM1.leadid = lead1.id;
CmpnM1.campaignid = cmpn1.id;
insert CmpnM1;
}
integer theNewLead = [select count() from Lead where Campaign_Name__c = 'TestInsert' limit 1];
if(theNewLead > 0){
System.Assert(true);
}
else{
System.Assert(false);
}
System.RunAs(SalesOps){
CampaignMember CmpnM2 = new CampaignMember();
CmpnM2.leadid = lead2.id;
CmpnM2.campaignid = cmpn1.id;
insert CmpnM2;
}
integer theNewLead2 = [select count() from Lead where Email_Inside_Sales_Rep__c > 0 limit 1];
if(theNewLead2 > 0){
System.Assert(true);
}
else{
System.Assert(false);
}
System.RunAs(SalesOps){
CampaignMember CmpnM3 = new CampaignMember();
CmpnM3.contactid = contct.id;
CmpnM3.campaignid = cmpn1.id;
insert CmpnM3;
}
integer theNewAcct = [select count() from Account where Email_CRM__c > 0 limit 1];
if(theNewAcct == 0){
System.Assert(true);
}
else{
System.Assert(false);
}
acct.AccountManager__c = 'testAM';
acct.Email_CRM__c = 0;
update acct;
System.RunAs(SalesOps){
CampaignMember CmpnM4 = new CampaignMember();
CmpnM4.contactid = contct.id;
CmpnM4.campaignid = cmpn2.id;
insert CmpnM4;
}
integer theNewAcct2 = [select count() from Account where Email_AM__c > 0 limit 1];
if(theNewAcct2 > 0){
System.Assert(true);
}
else{
System.Assert(false);
}
acct.Customer_Relationship_Manager_Primary__c = 'testCRM';
acct.Email_AM__c = 0;
update acct;
System.RunAs(SalesOps){
CampaignMember CmpnM5 = new CampaignMember();
CmpnM5.contactid = contct.id;
CmpnM5.campaignid = cmpn3.id;
insert CmpnM5;
}
integer theNewAcct3 = [select count() from Account where Email_CRM__c > 0 limit 1];
if(theNewAcct3 > 0){
System.Assert(true);
}
else{
System.Assert(false);
}
}
}
The error that I am getting has to do with the fact that my queries are returning a count of 0, and as a result evaluating false. I can't figure out why this is, everything is working properly when I run actual sandbox tests on the objects. Can someone please help me with this?
P.S. Here's the code for the trigger and the error messages:
trigger campaign_name_push on CampaignMember (after insert, after update) {
list<CampaignMember> theCampMemb = new list<CampaignMember>();
list<CampaignMember> theCampMemb2 = new list<CampaignMember>();
list<Id> theCampaigns = new list<Id>();
list<Id> theLeads = new list<Id>();
list<Id> theContacts = new list<Id>();
list<Id> theAccounts = new list<Id>();
for(CampaignMember cpmb : trigger.new) {
if(cpmb.leadid <> null) {
theCampMemb.add(cpmb);
theCampaigns.add(cpmb.campaignid);
theLeads.add(cpmb.leadid);
}
else if(cpmb.contactid <> null){
theCampMemb2.add(cpmb);
theContacts.add(cpmb.contactid);
}
}
map<Id,Campaign> campNames = new Map<Id,Campaign>([Select Name from Campaign where Id in :theCampaigns]);
map<Id,Lead> leadNames = new Map<Id,Lead>([Select Campaign_Name__c from Lead where Id in :theLeads]);
map<Id,Contact> AcctIds = new Map<Id,Contact>([Select AccountId from Contact where Id in :theContacts]);
for(Id getaccts : theContacts){
theAccounts.add(AcctIds.get(getaccts).AccountId);
}
map<Id,Account> AcctManagers = new Map<Id,Account>([Select AccountManager__c, Customer_Relationship_Manager_Primary__c from Account where Id in :theAccounts]);
list<Lead> UpdateLeads = new list<Lead>();
list<Account> UpdateAccounts = new list<Account>();
system.debug('before cm loop');
for(CampaignMember cm : theCampMemb){
system.debug('in cm loop');
Lead l = new Lead(Id = cm.LeadId);
l.Campaign_Name__c = campNames.get(cm.CampaignId).name;
system.debug('after getting campaign_name' + l.Campaign_Name__c);
if(leadNames.get(cm.LeadId).Campaign_Name__c <> null){
l.Email_Inside_Sales_Rep__c = 1;
system.debug('after setting inside sales rep');
}
UpdateLeads.add(l);
}
for(CampaignMember cm2 : theCampMemb2){
String AM = AcctManagers.get(AcctIds.get(cm2.contactid).AccountId).AccountManager__c;
String CRM = AcctManagers.get(AcctIds.get(cm2.contactid).AccountId).Customer_Relationship_Manager_Primary__c;
Account a = new Account(Id = (AcctIds.get(cm2.contactid).AccountId));
a.Email_AM__c = 1;
if(AM <> CRM) a.Email_CRM__c = 1;
a.ContactId__c = cm2.contactid;
UpdateAccounts.add(a);
}
Update UpdateLeads;
Update UpdateAccounts;
}
Error Messages:
P.P.S. Whenever I put the code in it seems to reformat like this, so if anyone has any advice on how to fix this or would like me to send them the files, please email me.
- Geof131313
- November 10, 2009
- Like
- 0
- Continue reading or reply
Time-off manager to manage sick leave
I'm investaging time-off manager package to manage PTO requests for my organization. I have installed it to my sandbox and created some dummy information. Annual leave and paid time off work perfectly, the time-off balance is adjusted automatically, but I dont know how to create sick leave which shouldnt deduct the accrued time-off.
Does anyone have the experience of using this package in your organization? How do you manage sick-leave? Or is this package doesnt have the ability to manage sick-leaves?
Thank for your help in advance.
Yosef
- kapalselam
- August 26, 2008
- Like
- 0
- Continue reading or reply
data loader question
- BK
- November 10, 2005
- Like
- 0
- Continue reading or reply