• K_dev
  • NEWBIE
  • 30 Points
  • Member since 2010

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 25
    Questions
  • 52
    Replies

AND(ISCHANGED( Provider_City__c ) || 
ISCHANGED( Provider_Country__c ) || 
ISCHANGED( Provider_State__c ) || 
ISCHANGED( Provider_Street__c ) || 
ISCHANGED( Provider_zip_postal_code__c ), $User.Id <> '005i0000001jkrK')

 
I need this validation to fire after first update is done. That means if anyone wants to change these for the second time these fields must be locked.
 
CAn you please check the possibility created date or last modified also not working because they will change other fields on the same record.
  • December 12, 2013
  • Like
  • 0

Hi 

 

Can anyone help me in converting this trigger into calling a batch class.

 

As it is not sufficient for our bulk loading of 4 millions data.

 

Here is the trigger:

 

trigger createacc on Contact (after insert) {
list<Contact > con=[select id,firstname ,lastname from contact where id in:Trigger.newMap.keySet()];
list<account >acc =new list<account>();
list<contact>cc1 =new list<contact>();
for(contact c : con)
{
account a =new account ();

a.name =  c.FirstName != null ? c.FirstName + ' ' + c.LastName : c.LastName;
acc.add(a);

}
insert acc;
for(account a1:acc){
system.debug('---------------------this is id --------------------'+a1.id);
for(contact c : con){
c.accountid=a1.id;
cc1.add(c);
}
}
update cc1;
}

 

 

I have a format please update me exact correct code works for my scenario:

 

trigger insertAccount on Contact (after insert) {
Map<id, Contact> contacts = new Map<id, Contact>();
for (Integer i=0;i<Trigger.new.size();i++) {

contacts.put(Trigger.new[i].Id, Trigger.new[i]);

}
// You can execute batch apex using trigger using below codes
if (contacts.size() > 0) {
Database.executeBatch(new InsertAccounts(contacts));
}
}

 

global class InsertAccounts implements Database.Batchable<sObject> {
//map of contactid - contact
Map<Id, Contact> contactMap = new Map<Id, Contact>();
global InsertAccounts(Map<Id, Contact> contacts) {
ContactMap = contacts;
}
global Database.QueryLocator start(Database.BatchableContext BC) {
return DataBase.getQueryLocator([SELECT Id,FirstName, LastName,AccountId FROM Contact WHERE accountID IN : contactMap.keySet()]);
}
global void execute(Database.BatchableContext BC,List<Account> scopeAcc) {

for (Integer i=0;i<scopeAcc.size();i++){
scopeAcc.get(i).Area__c=ownerMap.get(scopeAcc.get(i).OwnerId).Team__c;
}
update scopeAcc;
}
global void finish(Database.BatchableContext BC) {
//Send an email to the User after your batch completes
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
String[] toAddresses = new String[] {'info@theblogreaders.com'};
mail.setToAddresses(toAddresses);
mail.setSubject('Apex Batch Job is done');
mail.setPlainTextBody('The batch Apex Job Processed Successfully');
Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
}
}

 

  • December 03, 2013
  • Like
  • 0

 

trigger createacc on Contact (after insert) {
list<Contact > con=[select id,firstname ,lastname from contact where id in:Trigger.newMap.keySet()];
list<account >acc =new list<account>();
list<contact>cc1 =new list<contact>();
for(contact c : con)
{
account a =new account ();

a.name = c.FirstName != null ? c.FirstName + ' ' + c.LastName : c.LastName;
acc.add(a);

}
insert acc;
for(account a1:acc){
system.debug('---------------------this is id --------------------'+a1.id);
for(contact c : con){
c.accountid=a1.id;
cc1.add(c);
}
}
update cc1;
}

  • December 03, 2013
  • Like
  • 0

I have a req saying email the attachments  to all contacts whose preference is email (dropdown field)

we have 5000 different contacts must be emailed with their attachments every month
it is one contact having a child object   CBR reports has attachment pdfs need to be emailed with one click. How is it possible.ours is enterprise editioon.
 
Creating a VF page collects contacts child records and their attachments to send email how?
 
Creating a javascript button that calls a batch class which sorts out all of these records and their emails sending the attachments?
 
Please let me know the best solution as it is a monthly recurring event by admin and share some code snippet which helps for this master detail attachment pdfs sending from contact.
  • November 18, 2013
  • Like
  • 0

Our architecture is that we are storing contact info from a NPPES data base which they will provide monthly 5000 contacts 

 

we need to load into salesforce contacts but immediately we have to create an account with contact firstname,lastname .

 

And also need to verify if this firstname, lastname already exists must attach the contact to that account if not creat new account.

 

So how to achieve this any suggestions or code snippets either bulk trigger,batch,@future class which best fits to my

 

 

requirement Iam pretty new to development.Please let me know .

  • November 15, 2013
  • Like
  • 0

Please convert into a formula that I can enter in a formula editor of workflow.

 

descString += posToUpdate.Name != NULL ? posToUpdate.Name : '' ;
descString += dbPosition.VanaHCM__Position_Title__c != NULL ? '-'+ dbPosition.VanaHCM__Position_Title__c: '' ;
descString += dbPosition.Hire_Type__c != NULL ? '-'+ dbPosition.Hire_Type__c.left(1): '' ;
descString += posToUpdate.Funding_Type__c != NULL ? + posToUpdate.Funding_Type__c.left(1): '' ;
descString += posToUpdate.Funding_Status__c != NULL ? + posToUpdate.Funding_Status__c.left(1): '' ;
descString += posToUpdate.Position_FTE__c != NULL ? '-'+posToUpdate.Position_FTE__c: '' ;
if(descString.startsWith('-') && descString.length() >0){
descString = descString.substring(1);

  • October 30, 2013
  • Like
  • 0

 

 

I want this string must be updated when position Title field is changed or modified.

 

Please let me know the tweek for this!

 

descString = '';
/*added left (1) in needed strings*/
descString += posToUpdate.Name != NULL ? posToUpdate.Name : '' ;
descString += dbPosition.VanaHCM__Position_Title__c != NULL ? '-'+ dbPosition.VanaHCM__Position_Title__c: '' ;
descString += dbPosition.Hire_Type__c != NULL ? '-'+ dbPosition.Hire_Type__c.left(1): '' ;
descString += posToUpdate.Funding_Type__c != NULL ? + posToUpdate.Funding_Type__c.left(1): '' ;
descString += posToUpdate.Funding_Status__c != NULL ? + posToUpdate.Funding_Status__c.left(1): '' ;
descString += posToUpdate.Position_FTE__c != NULL ? '-'+posToUpdate.Position_FTE__c: '' ;
if(descString.startsWith('-') && descString.length() >0){
descString = descString.substring(1);
}
posToUpdate.Descriptive_ID__c = descString;
listOfPositionToUpdate.add(posToUpdate);
}

  • October 30, 2013
  • Like
  • 0

Hi 

 

My issue is my Descriptive field is getting updated from a trigger in this format

Descriptive ID

Graphic Designer-International-General-Regular-0.75
 

Required format 

 

Descriptive ID  G-I-G-R-0.75

 

Please modify this code

 

descString = '';
descString += posToUpdate.Name != NULL ? posToUpdate.Name : '' ;
descString += dbPosition.VanaHCM__Position_Title__c != NULL ? '-'+dbPosition.VanaHCM__Position_Title__c: '' ;
descString += dbPosition.Hire_Type__c != NULL ? '-'+dbPosition.Hire_Type__c: '' ;
descString += posToUpdate.Funding_Type__c != NULL ? '-'+posToUpdate.Funding_Type__c: '' ;
descString += posToUpdate.Funding_Status__c != NULL ? '-'+posToUpdate.Funding_Status__c: '' ;
descString += posToUpdate.Position_FTE__c != NULL ? '-'+posToUpdate.Position_FTE__c: '' ;
if(descString.startsWith('-') && descString.length() >0){
descString = descString.substring(1);
}
posToUpdate.Descriptive_ID__c = descString;

  • October 23, 2013
  • Like
  • 0

Hi 

 

Anybody suggest me the best possible ways to integrate with M-files http://www.m-files.com/en/

http://www.chromeriver.com/,Active directory.

 

In salesforce Vana is deployed from app exchange so these custom objects are only prest in salesforce there is no data.

 

What I need to give M-files if I give a Partner WSDL to them they will build the code to reach salesforce and insert data?

 

How the media files, videos, pdfs,word docs and so on to be pushed from M-files to salesforce?

 

 

 

 

  • October 02, 2013
  • Like
  • 0

HI

 

Iam looking to add an error when customerNote__c object records is edited only when createdBy= UserInfo.getuserId

 

 

 

 
  • August 23, 2013
  • Like
  • 0
Can anybody  check and tweak this trigger according to my requirement.
 

  Create a new read only field on Customer for "Latest Call List"  Text 30 (or whatever field length the call list name is).  Every time a call list object is added to Person Account, a trigger updates this field with the Call List name(whichever is the latest record).

 Call List is Master detail to Person Account.So whenever a new calllist is added immediately latest_Call_List__c field on account must be updated with the call list name.
trigger UpdatenameFieldstoAccount on call_list__c (after insert, after delete, after update)
{
    Set<String> accountIds = new Set<String>();
    
    if(Trigger.isDelete)
    {
        for( Call_List__c calllist : Trigger.old)
        {
            accountIds.add(calllist.Account__c);
        }
    }
    else
    {
        for(Call_List__c calllist : Trigger.new)
        {
            accountIds.add(calllist.Account__c);
        }
    }
    
    List<Account> accounts = new List<Account>();
    for(Account acc : [select latest_Call_List__c, (select Name from Call_List__r order by CreatedDate asc) from Account where Id in :accountIds])
    {
       acc.latest_Call_List__c = null;
        for(Call_List__c calllist : acc.call_List__r)
        {
       acc.latest_Call_List__c = calllist.Name;
        accounts.add(acc);
    }
    if(accounts.size() > 0)
    {
        update accounts;
    }
}
  • August 14, 2013
  • Like
  • 0
Developer script exception createopp : createopp: execution of AfterUpdate caused by: line 31, column 35: trigger body is invalid and failed recompilation: Invalid field Ownerid for SObject Call_List__c
 
Apex script unhandled trigger exception by user/organization: 005800000057Bpj/ 00D80000000PQ4F

createopp: execution of AfterUpdate

caused by: line 31, column 35: trigger body is invalid and failed recompilation: Invalid field Ownerid for SObject Call_List__c
 
can anyone please let me know ?
 
  • August 13, 2013
  • Like
  • 0

I need a validation rule which status picklist is "converted " then this field must be readonly for all the profiles except to system admin.

 

 

Please help me!

  • July 29, 2013
  • Like
  • 0


trigger createopp on Call_Abandon_List__c (after insert,after update)
{
List<opportunity> opps=new List<opportunity>();
for(Call_Abandon_List__c ca:Trigger.New)
{
/* if(Trigger.IsInsert && ca.Status__c=='converted')
{
opportunity O=new Opportunity();
O.Name='ca.Name';
O.Product_Id__c=ca.Product__c;

opps.add(O);
}
*/
// after update
if(Trigger.IsUpdate && ca.Status__c!=Trigger.oldMap.get(ca.Id).Status__c && ca.Status__c=='converted'&&ca.Converted_to_Opportunity__c==false)
{
opportunity o=new Opportunity();
O.Name=ca.Name;
o.Accountid = ca.Account__c;
o.Product_Id__c=ca.Product__c;
o.StageName = 'New';
o.Probability = 10;
o.CloseDate= Date.Today();
o.LeadSource = 'Abandon List';
o.Secondary_User__c = ca.Ownerid;
QueueSobject que = [Select Id, Queue.Id From QueueSobject Where Queue.DeveloperName='calllist_queue' Limit 1];
o.Ownerid = que.Queue.Id;
o.Converted_to_Opportunity__c=true;
opps.add(o);
system.debug('opportunity is '+o);

}
}

if(!opps.IsEmpty())
{
system.debug('********entered if');
try
{
insert opps;
}
catch(Exception e)
{
system.debug('******exception thrown'+e);
}
}
}

  • July 26, 2013
  • Like
  • 0

 

trigger create_oli on Opportunity (after insert) 
{
    list<OpportunityLineItem> lst_oli=new list<OpportunityLineItem >();     
    map<string,string> pdcts=new map<string,string>();
    for(Opportunity o:Trigger.New)
    {
        if(o.Product_Id__c!=null)
        {
            pdcts.put(o.Id,o.Product_Id__c);            
        }
    }
    if(!pdcts.IsEmpty())
    {
        map<String,string> pbe_map=new map<string,string>();
        list<pricebookentry> pbe=[select id, Product2Id  from PricebookEntry where Product2Id IN:pdcts.values()];
        for(pricebookentry p:pbe)
        {
            pbe_map.put(p.Product2Id,p.Id);
        }
        for(string s:pdcts.Keyset())
        {
            if(pbe_map.containsKey(pdcts.get(s)))
            {
                OpportunityLineItem oli=new OpportunityLineItem();
                oli.Opportunityid=s;
                //oli.Product2=o.Product_Id__c;
                oli.Quantity = 1;
                oli.PricebookEntryId=pbe_map.get(pdcts.get(s));
                oli.TotalPrice=1000;
                lst_oli.add(oli);
            }
        }
        if(!lst_oli.IsEmpty())
        {
            insert lst_oli;
        }
    }
}
  • July 26, 2013
  • Like
  • 0

Can anyone please let me know why it is not taking the stage and close date in the trigger.

 

trigger createopp on Call_Abandon_List__c (after insert,after update)
{
List<opportunity> opps=new List<opportunity>();
for(Call_Abandon_List__c ca:Trigger.New)
{
/* if(Trigger.IsInsert && ca.Status__c=='converted')
{
opportunity O=new Opportunity();
O.Name='ca.Name';
O.Product_Id__c=ca.Product__c;

opps.add(O);
}
*/
// after update
if(Trigger.IsUpdate && ca.Status__c!=Trigger.oldMap.get(ca.Id).Status__c && ca.Status__c=='converted'&&ca.Converted_to_Opportunity__c==false)
{
opportunity o=new Opportunity();
O.Name=ca.Name;
o.Accountid = ca.Account__c;
o.Product_Id__c=ca.Product__c;
o.StageName = 'New';
o.Probability = 10;
o.CloseDate= System.today();
o.LeadSource = 'Abandon List';
o.Secondary_Owner__c = ca.Ownerid;
o.Ownerid = '00GQ0000001wKES';
opps.add(o);
o.Converted_to_Opportunity__c=true;

}
}

if(!opps.IsEmpty())
{
try
{
insert opps;
}
catch(Exception e){system.debug(e);}
}
}

  • July 25, 2013
  • Like
  • 0

cAN ANYONE HELP ME I CREATED THE PRODUCT_Id__C ON OPPORTUNITY STILL IT SAYS SAME ERROR

 

trigger create_oli on Opportunity (after insert)
{
list<OpportunityLineItem> lst_oli=new list<OpportunityLineItem >();
map<string,string> pdcts=new map<string,string>();
for(Opportunity o:Trigger.New)
{
if(o.Product_Id__c!=null)
{
pdcts.put(o.Id,o.Product_Id__c);
}
}
if(!pdcts.IsEmpty())
{
map<String,string> pbe_map=new map<string,string>();
list<pricebookentry> pbe=[select id, Product2Id from PricebookEntry where Product2Id IN:pdcts.values()];
for(pricebookentry p:pbe)
{
pbe_map.put(p.Product2Id,p.Id);
}
for(string s:pdcts.Keyset())
{
if(pbe_map.containsKey(pdcts.get(s)))
{
OpportunityLineItem oli=new OpportunityLineItem();
oli.Opportunityid=s;
//oli.Product2=o.Product_Id__c;
oli.Quantity = 1;
oli.PricebookEntryId=pbe_map.get(pdcts.get(s));
oli.TotalPrice=1000;
lst_oli.add(oli);
}
}
if(!lst_oli.IsEmpty())
{
insert lst_oli;
}
}
}

  • July 25, 2013
  • Like
  • 0

 

can anyone help about this error

 

trigger createopp on Call_Abandon_List__c (after insert,after update)
{
List<opportunity> opps=new List<opportunity>();
for(Call_Abandon_List__c ca:Trigger.New)
{
if(Trigger.IsInsert && ca.Status__c=='converted')
{
opportunity O=new Opportunity();
O.Name='ca.Name';
O.Product_Id__c=ca.Product__c;

opps.add(O);
}
if(Trigger.IsUpdate && ca.Status__c!=Trigger.oldMap.get(ca.Id).Status__c && ca.Status__c=='converted')
{
opportunity o=new Opportunity();
O.Name=ca.Name;
o.Account = 'ca.Account__c';
o.Product_Id__c=ca.Product__c;
o.StageName = 'New';
o.CloseDate=Date.today();
o.LeadSource = 'Abandon List';
o.Secondary_Owner__c = ca.Owner.Name;
o.Converted_to_Opportunity__c=true;
opps.add(o);

}
}

if(!opps.IsEmpty())
{
try
{
insert opps;
}
catch(Exception e){system.debug(e);}
}
}

  • July 25, 2013
  • Like
  • 0


trigger CreateopportunityonConverted on calllist__c (after insert, after update) {
list<string> callids=new list<String>();
for(callist__c o: trigger.new){
if(o.status__c == converted && o.converted_to_Opp == false){
callids.add(o.id);
}
}
if(!callids.IsEmpty())


calllist object fields to be converted into opportunity and opportunity line items.There is a account and opportunity lookup.
While opportunity creation make close date to today and stage to new.There is a secondary owner field which must be filled with calllist record owner in convertion.
{
calllist[] OLI = [Select UnitPrice, Quantity,OpportunityId, PricebookEntry.Product2Id, PricebookEntry.Product2.Name, Description, Converted_to_opp__c
From OpportunityLineItem
where OpportunityId IN:oppIds and Converted_to_opp__c = false];
Asset[] ast = new Asset[]{};
Asset a = new Asset();
for(OpportunityLineItem ol: OLI){
a = new Asset();
a.AccountId = Trigger.NewMap.get(ol.OpportunityId).AccountId;
a.Product2Id = ol.PricebookEntry.Product2Id;
a.Quantity = ol.Quantity;
a.Price = ol.UnitPrice;
a.PurchaseDate = Trigger.NewMap.get(ol.OpportunityId).CloseDate;

a.Status = 'Purchased';
a.Description = ol.Description;
a.Name = ol.PricebookEntry.Product2.Name;
ast.add(a);
ol.Converted_to_Assets__c = true;
}

update OLI;
insert ast;

}

 

Thanks in advance

  • July 23, 2013
  • Like
  • 0

I want a formula if publication code text field equals DWT,DGP,DWP,SRP then update a picklist monthly,one year , 2 years.

  • July 15, 2013
  • Like
  • 0

Hi 

 

Can anyone help me in converting this trigger into calling a batch class.

 

As it is not sufficient for our bulk loading of 4 millions data.

 

Here is the trigger:

 

trigger createacc on Contact (after insert) {
list<Contact > con=[select id,firstname ,lastname from contact where id in:Trigger.newMap.keySet()];
list<account >acc =new list<account>();
list<contact>cc1 =new list<contact>();
for(contact c : con)
{
account a =new account ();

a.name =  c.FirstName != null ? c.FirstName + ' ' + c.LastName : c.LastName;
acc.add(a);

}
insert acc;
for(account a1:acc){
system.debug('---------------------this is id --------------------'+a1.id);
for(contact c : con){
c.accountid=a1.id;
cc1.add(c);
}
}
update cc1;
}

 

 

I have a format please update me exact correct code works for my scenario:

 

trigger insertAccount on Contact (after insert) {
Map<id, Contact> contacts = new Map<id, Contact>();
for (Integer i=0;i<Trigger.new.size();i++) {

contacts.put(Trigger.new[i].Id, Trigger.new[i]);

}
// You can execute batch apex using trigger using below codes
if (contacts.size() > 0) {
Database.executeBatch(new InsertAccounts(contacts));
}
}

 

global class InsertAccounts implements Database.Batchable<sObject> {
//map of contactid - contact
Map<Id, Contact> contactMap = new Map<Id, Contact>();
global InsertAccounts(Map<Id, Contact> contacts) {
ContactMap = contacts;
}
global Database.QueryLocator start(Database.BatchableContext BC) {
return DataBase.getQueryLocator([SELECT Id,FirstName, LastName,AccountId FROM Contact WHERE accountID IN : contactMap.keySet()]);
}
global void execute(Database.BatchableContext BC,List<Account> scopeAcc) {

for (Integer i=0;i<scopeAcc.size();i++){
scopeAcc.get(i).Area__c=ownerMap.get(scopeAcc.get(i).OwnerId).Team__c;
}
update scopeAcc;
}
global void finish(Database.BatchableContext BC) {
//Send an email to the User after your batch completes
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
String[] toAddresses = new String[] {'info@theblogreaders.com'};
mail.setToAddresses(toAddresses);
mail.setSubject('Apex Batch Job is done');
mail.setPlainTextBody('The batch Apex Job Processed Successfully');
Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
}
}

 

  • December 03, 2013
  • Like
  • 0

 

trigger createacc on Contact (after insert) {
list<Contact > con=[select id,firstname ,lastname from contact where id in:Trigger.newMap.keySet()];
list<account >acc =new list<account>();
list<contact>cc1 =new list<contact>();
for(contact c : con)
{
account a =new account ();

a.name = c.FirstName != null ? c.FirstName + ' ' + c.LastName : c.LastName;
acc.add(a);

}
insert acc;
for(account a1:acc){
system.debug('---------------------this is id --------------------'+a1.id);
for(contact c : con){
c.accountid=a1.id;
cc1.add(c);
}
}
update cc1;
}

  • December 03, 2013
  • Like
  • 0

Our architecture is that we are storing contact info from a NPPES data base which they will provide monthly 5000 contacts 

 

we need to load into salesforce contacts but immediately we have to create an account with contact firstname,lastname .

 

And also need to verify if this firstname, lastname already exists must attach the contact to that account if not creat new account.

 

So how to achieve this any suggestions or code snippets either bulk trigger,batch,@future class which best fits to my

 

 

requirement Iam pretty new to development.Please let me know .

  • November 15, 2013
  • Like
  • 0