• Ashw
  • NEWBIE
  • 45 Points
  • Member since 2014
  • mr
  • nun

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 11
    Questions
  • 12
    Replies
I have written a trigger logic to update a custom field verion_Id__c with contentversionID but facing the error as "You cannot set custom fields or tags" I need experts to help in fixing the issue. below is the code.
 
if(trigger.IsAfter){
        if(trigger.IsInsert){
            list<ContentVersion> lstObj = [Select id,VersionNumber,version_id__c from ContentVersion where Id IN: Trigger.newMap.keySet()];
            for(ContentVersion con: lstObj ){
                if(con.VersionNumber == '1' ) con.version_id__c = con.Id;
            }
            update lstObj;
        }
    }

​​​​​​​
  • August 24, 2020
  • Like
  • 0
I am not able to create force.com project in eclipse. Added IDE and I able to see force.com project but when I click on force.com project no action is happening. I installed the latest Eclipse IDE 2019‑03 and java version is JDK 12. Please, can anyone help me how to fix the issue so that I can add force.com project
  • April 26, 2019
  • Like
  • 0
Is it possible to add a custom button to Campaign Member Column View, next to the "remove" "update status" buttons? Please help me with the solution to this.

User-added image
 
  • April 19, 2019
  • Like
  • 0
Is it possible to display account name with out accounts tail name 
example account name: Apple cooperation limit but need to display only Apple 
              Account name: salesforce Pvt. Ltd need to display only salesforce in vf page this way only account names on vf page with out tail names. Please provide your valuable suggestion 

  • September 23, 2015
  • Like
  • 0
public class activate {

}

Test class:

@isTest
private class emptyclass_Test{
    static testmethod void mycodecoverage(){
    test.startTest();
        activate em = new activate();
        
        test.stopTest();
    }
}
  • March 26, 2015
  • Like
  • 0
User-added image
<apex:page controller="wrapper3cls" contentType="text/xml">
    <apex:form >
        <apex:pageblock >
            <apex:pageblocktable value="{!lstwrap}" var="awrap">
            <apex:column headerValue="Contacts" >
                    <apex:repeat value="{!awrap.lst}" var="c">
                        <apex:commandLink value="approve" rendered="{!if((awrap.acc.name=='GenePoint'),true,false)}" action="/apex/displaypage?id='+rId"/>
                        <apex:param name="rId" value="{!c.Id}" assignTo="{!rId}"/>
                    </apex:repeat>
            </apex:column>
                <apex:column value="{!awrap.acc.name}"/>
                <apex:column value="{!awrap.acc.phone}"/>
                <apex:column value="{!awrap.acc.fax}"/>
            </apex:pageblocktable>
        </apex:pageblock>
    </apex:form>
</apex:page>
  • February 23, 2015
  • Like
  • 0
trigger InvoiceAccountUpdate on Client_Invoice__c (before insert,before update){
    
    map<Id,Id> mapOppAccounts = new map<Id,Id>();
    list<Id> lstOpportunityIds = new list<Id>();
       
        for(Client_Invoice__c ObjInvoice : trigger.new){
            lstOpportunityIds.add(objInvoice.opportunity__c);
        }
		list<Opportunity> lstopp = [select Id,Account.ID from Opportunity where Id In:lstOpportunityIds];
        for(Opportunity objOpportunity : lstopp){
            mapOppAccounts.put(objOpportunity.Id,objOpportunity.Account.Id);
        } 
        for(Client_Invoice__c obj : trigger.new) {
            if(mapOppAccounts.get(obj.opportunity__c)!= Null)
            obj.Account__c= mapOppAccounts.get(obj.opportunity__c);
        } 	
        
}

  • September 17, 2014
  • Like
  • 0
public with sharing class preCall_cls {

    public Void Change() {
        if(conId != '--None--'){
            Contact obj = [select id,name,AccountId,Phone from Contact where name =: conId];
                co.AccountId= obj.AccountId;
                co.Phone= obj.Phone;
        }
        else
        {
            ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.FATAL, 'Please select correct value');
            apexpages.addmessage(myMsg);
            co.AccountId='';
            co.Phone='';
        }  
    }

        public list<SelectOption> AccValues {get;set;}
        public Contact co {get;set;}
        public string conId {get;set;} 
        
        public preCall_cls(){
                AccValues = new List<SelectOption>();
                list<Contact> lst = [select id,name,AccountId,Phone from Contact];
                    AccValues.add(new selectoption('--None--','--None--'));
                for(Contact con : lst){
                        AccValues.add(new selectoption(con.id,con.Name));
                }
                co = new Contact();
                //co = [select id,name,AccountId,Phone from Contact where name =: conId];
        }
}

  • August 07, 2014
  • Like
  • 0
As a new comer to salesforce i know how to write a trigger and class but how to conver the below code to class and call it in trigger, so please help me how to do this. Thanks guys in Advance 

Set<Id> accids = new Set<Id>();
	if(trigger.isInsert || trigger.isUpdate ||trigger.isUndelete){
		for(Contact con : trigger.new){
			accids.add(con.accountId);
		}
	}
	if(trigger.isUpdate || trigger.isdelete){
		for(Contact con : trigger.old){
			accids.add(con.accountId);
		}	
	}	
	
	List<account> lst = [Select id, No_Of_contacts__c,(Select id from Contacts) from account where Id in: accids];
	for(Account acc : lst){
		acc.no_of_contacts__c = acc.contacts.size();
	}
	update lst;


  • May 27, 2014
  • Like
  • 0
Hi I'M new to salesforce.com. I'm unable to do code coverage for this below coved my test code is covering 63% only what i have learnt from my training class is simply by covering methods in the class we will get 75%

class:
--------
public with sharing class AccFieldsIn2DiffVfToSave_cls {

    public PageReference doSave() {
        insert objA;
        return (new pagereference('/apex/AccFieldsIn2DiffVfToSave2?id='+obja.Id).setredirect(true));
    }


    public Account objA { get; set; }
   
    public AccFieldsIn2DiffVfToSave_cls(){
        objA = new Account();
    }
}

test class:
--------------

@isTest
private class AccFieldsIn2DiffVfToSave2_tst{
    static testmethod void mytest(){
   
        AccFieldsIn2DiffVfToSave2 obj = new AccFieldsIn2DiffVfToSave2 ();
                  
            obj.doSave();
    }
}
  • May 02, 2014
  • Like
  • 0
if in Opportunity stagename is closed won & closed lost and amount is already exist and then it should not be editable.

trigger OppTrg on Opportunity (before update) {

Opportunity newopp = trigger.new[0];
Opportunity oldOpp = trigger.old[0];

if(oldOpp.StageName == 'Closed Won' || oldOpp.StageName == 'Closed Lost'){
  if(oldOpp.Amount != newOpp.Amount){
   newopp.addError('YOu cannot change the amount when Opp is set to Closed Won or Closed lost');
  }

}

}
  • March 01, 2014
  • Like
  • 0
I am not able to create force.com project in eclipse. Added IDE and I able to see force.com project but when I click on force.com project no action is happening. I installed the latest Eclipse IDE 2019‑03 and java version is JDK 12. Please, can anyone help me how to fix the issue so that I can add force.com project
  • April 26, 2019
  • Like
  • 0
Hi All,

We have one Formula field called "Contract End Date"  in Opportunity object ,Needs  to populate the "Contract End Date" on the Account "Service Contract End Date"  at the time of opp is created.

Can any one please help me to creating a trigger on above senario.

Thanks
 
Is it possible to display account name with out accounts tail name 
example account name: Apple cooperation limit but need to display only Apple 
              Account name: salesforce Pvt. Ltd need to display only salesforce in vf page this way only account names on vf page with out tail names. Please provide your valuable suggestion 

  • September 23, 2015
  • Like
  • 0
public class activate {

}

Test class:

@isTest
private class emptyclass_Test{
    static testmethod void mycodecoverage(){
    test.startTest();
        activate em = new activate();
        
        test.stopTest();
    }
}
  • March 26, 2015
  • Like
  • 0
User-added image
<apex:page controller="wrapper3cls" contentType="text/xml">
    <apex:form >
        <apex:pageblock >
            <apex:pageblocktable value="{!lstwrap}" var="awrap">
            <apex:column headerValue="Contacts" >
                    <apex:repeat value="{!awrap.lst}" var="c">
                        <apex:commandLink value="approve" rendered="{!if((awrap.acc.name=='GenePoint'),true,false)}" action="/apex/displaypage?id='+rId"/>
                        <apex:param name="rId" value="{!c.Id}" assignTo="{!rId}"/>
                    </apex:repeat>
            </apex:column>
                <apex:column value="{!awrap.acc.name}"/>
                <apex:column value="{!awrap.acc.phone}"/>
                <apex:column value="{!awrap.acc.fax}"/>
            </apex:pageblocktable>
        </apex:pageblock>
    </apex:form>
</apex:page>
  • February 23, 2015
  • Like
  • 0
trigger InvoiceAccountUpdate on Client_Invoice__c (before insert,before update){
    
    map<Id,Id> mapOppAccounts = new map<Id,Id>();
    list<Id> lstOpportunityIds = new list<Id>();
       
        for(Client_Invoice__c ObjInvoice : trigger.new){
            lstOpportunityIds.add(objInvoice.opportunity__c);
        }
		list<Opportunity> lstopp = [select Id,Account.ID from Opportunity where Id In:lstOpportunityIds];
        for(Opportunity objOpportunity : lstopp){
            mapOppAccounts.put(objOpportunity.Id,objOpportunity.Account.Id);
        } 
        for(Client_Invoice__c obj : trigger.new) {
            if(mapOppAccounts.get(obj.opportunity__c)!= Null)
            obj.Account__c= mapOppAccounts.get(obj.opportunity__c);
        } 	
        
}

  • September 17, 2014
  • Like
  • 0
public with sharing class preCall_cls {

    public Void Change() {
        if(conId != '--None--'){
            Contact obj = [select id,name,AccountId,Phone from Contact where name =: conId];
                co.AccountId= obj.AccountId;
                co.Phone= obj.Phone;
        }
        else
        {
            ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.FATAL, 'Please select correct value');
            apexpages.addmessage(myMsg);
            co.AccountId='';
            co.Phone='';
        }  
    }

        public list<SelectOption> AccValues {get;set;}
        public Contact co {get;set;}
        public string conId {get;set;} 
        
        public preCall_cls(){
                AccValues = new List<SelectOption>();
                list<Contact> lst = [select id,name,AccountId,Phone from Contact];
                    AccValues.add(new selectoption('--None--','--None--'));
                for(Contact con : lst){
                        AccValues.add(new selectoption(con.id,con.Name));
                }
                co = new Contact();
                //co = [select id,name,AccountId,Phone from Contact where name =: conId];
        }
}

  • August 07, 2014
  • Like
  • 0
As a new comer to salesforce i know how to write a trigger and class but how to conver the below code to class and call it in trigger, so please help me how to do this. Thanks guys in Advance 

Set<Id> accids = new Set<Id>();
	if(trigger.isInsert || trigger.isUpdate ||trigger.isUndelete){
		for(Contact con : trigger.new){
			accids.add(con.accountId);
		}
	}
	if(trigger.isUpdate || trigger.isdelete){
		for(Contact con : trigger.old){
			accids.add(con.accountId);
		}	
	}	
	
	List<account> lst = [Select id, No_Of_contacts__c,(Select id from Contacts) from account where Id in: accids];
	for(Account acc : lst){
		acc.no_of_contacts__c = acc.contacts.size();
	}
	update lst;


  • May 27, 2014
  • Like
  • 0
Hi I'M new to salesforce.com. I'm unable to do code coverage for this below coved my test code is covering 63% only what i have learnt from my training class is simply by covering methods in the class we will get 75%

class:
--------
public with sharing class AccFieldsIn2DiffVfToSave_cls {

    public PageReference doSave() {
        insert objA;
        return (new pagereference('/apex/AccFieldsIn2DiffVfToSave2?id='+obja.Id).setredirect(true));
    }


    public Account objA { get; set; }
   
    public AccFieldsIn2DiffVfToSave_cls(){
        objA = new Account();
    }
}

test class:
--------------

@isTest
private class AccFieldsIn2DiffVfToSave2_tst{
    static testmethod void mytest(){
   
        AccFieldsIn2DiffVfToSave2 obj = new AccFieldsIn2DiffVfToSave2 ();
                  
            obj.doSave();
    }
}
  • May 02, 2014
  • Like
  • 0