• Om Prakash
  • SMARTIE
  • 975 Points
  • Member since 2014
  • Product Head
  • 360 Degree Cloud


  • Chatter
    Feed
  • 32
    Best Answers
  • 0
    Likes Received
  • 2
    Likes Given
  • 1
    Questions
  • 134
    Replies
Hello,

insert cloneQuoteList; 

I am inserting the list of quote.
How can i get the Opportunity Id and Inserted qute id after the insert.

I want to use the Ids to insert the cloned quote line items

thank you
Hello,

I'm getting the error below.

Error: Compile Error: Constructor not defined: [ApexPages.StandardSetController].<Constructor>(Login_Information_Object__c) at line 22 column 46

for the Test Class below. The Test Class is for a Visualforce Page controller. Any assistance is greatly appreciated.
 
@isTest
public class VFTSIAITSplashPageController_UT {

    
    static testMethod void myTest() {
        Login_Information_Object__c lio=new Login_Information_Object__c();
       
        lio.LIO_Content__c='test';
        lio.LIO_End_Date__c=Date.today() + 30;
        lio.LIO_Start_Date__c=Date.today() + 1;
        lio.Show_On_Login__c=TRUE;
        lio.Subject__c='testing';
        insert lio;   
        
        PageReference pageRef1 = Page.TSIAInformationSplashPage;
        Test.setCurrentPage(pageRef1);
        pageRef1.getParameters().put('id',lio.Id);

        ApexPages.StandardSetController sc = new ApexPages.StandardSetController(lio);
        VFTSIAITSplashPageController testlio = new VFTSIAITSplashPageController (sc);
        
        testlio.save();    
 
        
        
    }
}

 
  • June 12, 2019
  • Like
  • 0
I have three batch classes, I want to execute all three batch classes through button click using visualforce page at the same time.
LoanofficerBatch lob = new LoanofficerBatch(); 
        database.executebatch(lob);
        
        RealtorBatch rb = new RealtorBatch(); 
        database.executebatch(rb);
        
        BuilderBatch bb = new BuilderBatch(); 
        database.executebatch(bb);

please help
trigger trg4 on Account (after insert) 
{
    Map<Id,Decimal> map1 = new Map<Id,Decimal>();
    for(Account a : trigger.new)
    {
        map1.put(a.id, a.No_of_Contacts__c);
    }
    
    
   List<Contact> con = new List<Contact>();
    if(trigger.isinsert && trigger.isafter)
    {
        if(map1.size() > 0 && map1 !=null)
        {
            for(Id a: map1.keySet())
            {
                for(integer i=1;i<=map1.get(a) ; i++)
                {
                    Contact c = new Contact();
                    c.LastName='Demo Contact';
                    c.AccountId=a;
                    c.Phone='454646';  
                    con.add(c);
                }
            }
        }
        INSERT con;
    }
}


Errors:
Variable does not exist: LastName
Variable does not exist: AccountId
Variable does not exist: Phone
DML requires SObject or SObject list type: List


Kindly help me to solve this problem in trigger.
Hi,

I want to write a trigger, which throws error message , when the accountname is changed from the cloned version of record.

I have tried writting code, somehow its not working

Can someone help

Please find the code below : 

trigger PreventChangeOfAccountName on Order (before update , after insert) {
    
    for (Order o : trigger.new){
        
       If  (o.isClone() && trigger.oldmap.get(o.Id).AccountId <> trigger.oldmap.get(o.Id).AccountId)
       {
           o.addError('Account Name for Cloned records cant be changed');
       }
    }
}  
Hi all,

I want to use the Username-Password OAuth Authentication Flow with a partner user license. However, when I try to do this call, i have an error.

As mentioned in the docs (https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/intro_understanding_username_password_oauth_flow.htm) this flow requires the security token with the password, but the partner user license doesn't have a security token.

This is the response when call the default endpoint:
{
    "error": "invalid_grant",
    "error_description": "authentication failure"
}

This is de response when i use the community URL:
{
    "error": "unsupported_grant_type",
    "error_description": "grant type not supported"
}
My question is if is possible to use this OAuth Flow with partner user (and how can I do this), or if only User-Agent or Web Server are supported for this license type (can't find this in docs).

Thanks!
Hi Guys, I am new to Visual force development and need some help.

I have created a custom link on my home page to run a scheduled job immediately. I need to create a VF page to do this but need some help in creating the page text.

What I need to run is the following:

TelesalesDataProcessor runJob = new TelesalesDataProcessor();
runJob.execute(null);

Any help would be appreciated.

Thanks

Alan

 
While creating an Opportunity record in Salesforce via REST API, even though the values for mandatory fields are not given, Salesforce accepts it and does not throw a validation error. For Ex: Account Name is mandatory in Salesforce UI while creating an Opportunity and it doesn't allow to create until we give a value for Account Name.

However if the same request is passed via REST API it accepts it.

Here is the sample request:
POST request 
/services/data/v40.0/sobjects/Opportunity
 { "Name": "test opportunity", "StageName": "Closed Lost","CloseDate": "2018-04-02"}

This request succeeds in creating an opportunity where in actual it should have given a validation error for Account Name field.

Is this behavior expected? Any help would be appreciated. 

Thanks
Hey, I currently have an Apex function which takes a name and an existing Contact, and if the current Contact name is our dummy name 'Dyreven' but the new name is NOT it updates the Contact name. Like this:
 
// Small method to check if the passed name variable is NOT 'Dyreven' but the current name is. Then replace 'Dyreven' with the new name

    private static Contact checkForUpdatedName(String name, Contact con){
        if (name != 'Dyreven') {
            if (con.LastName == 'Dyreven') {
                con.LastName = name;
                update con;
            }
        }
        return con;
    }

 
However, instead of having the dummy name hardcoded in the Apex I want my Apex to pull a list of dummy names from custom metadata and then check through all of them. So it should be possible to have a custom list of dummy names and then the Apex code would check against that list instead of against a hardcoded String like above.

How can I do this? Are lists supported as a custom metadata type?
Hi, I wrote a trigger to prevent the lead duplicates based on the mobile number and Email.

Am wondering to write a test class for the same trigger. My test class was not passed .can anyone give me the suggestion to how to write a flow for the test class.

My Trigger  code

Trigger leaddup17 on lead(before insert, After Update) {


    Set<String> setEmail = new Set<String>();
    Set<String> setnumber = new Set<String>();
    Set<String> setId = new Set<String>();
    
    for (Lead ld: Trigger.new) {
        if (ld.Phone != Null ||  ld.MobilePhone!=Null || ld.Whatsapp_Mobile__c!=Null || ld.Mobile_Additional__c!=Null|| ld.Phone_Additional__c!=Null 
            ){
                    
            setnumber.add(ld.MobilePhone);
            setnumber .add(ld.Whatsapp_Mobile__c);
            setnumber .add(ld.Mobile_Additional__c);
            setnumber .add(ld.Phone);
            setnumber .add(ld.Phone_Additional__c);
           
          }
        
        if (ld.Email!=null || ld.E_Mail_Additional__c!=Null){
            setEmail.add(ld.Email);
             setEmail.add(ld.Email);
             setEmail.add(ld.E_Mail_Additional__c);
            
        }
        setId.add(ld.id);
    }
        
    List<Lead> lstExistingLead = [Select id,Phone,Email,E_Mail_Additional__c,MobilePhone,Whatsapp_Mobile__c,Phone_Additional__c,Mobile_Additional__c from Lead where  ((email in :setEmail or E_Mail_Additional__c in : setEmail ) or
     (Phone in :setnumber or Phone_Additional__c in : setnumber  or Mobile_Additional__c in : setnumber   or Whatsapp_Mobile__c in :setnumber   or
     MobilePhone in : setnumber))    and (id not in :setId)];
    
    map < string, Lead > LeadsMap = new map < String, Lead > ();
   

    for (Lead ld: lstExistingLead) {
        if (ld.Email!=null || ld.E_Mail_Additional__c!=Null || ld.Phone != Null ||  ld.MobilePhone!=Null || ld.Whatsapp_Mobile__c!=Null || ld.Mobile_Additional__c!=Null|| ld.Phone_Additional__c!=Null )
        {
        
            LeadsMap .put(ld.Phone, ld);
             LeadsMap .put(ld.MobilePhone, ld);
              LeadsMap .put(ld.Whatsapp_Mobile__c, ld);
               LeadsMap .put(ld.Phone_Additional__c, ld);
                LeadsMap .put(ld.Mobile_Additional__c, ld);
                LeadsMap .put(ld.Email, ld);
             LeadsMap .put(ld.E_Mail_Additional__c, ld);
                 
        }   
          setId.add(ld.id);
    }

    for (Lead ld: Trigger.new) 
    {
    
    
        if ( Trigger.isInsert &&  ld.Email!=null || ld.E_Mail_Additional__c!=Null &&  ld.Phone == Null ||  ld.MobilePhone==Null || ld.Whatsapp_Mobile__c==Null || ld.Mobile_Additional__c==Null|| ld.Phone_Additional__c==Null 
        
        && ld.Email != trigger.oldMap.get(ld.Id).Email  ||
         ld.E_Mail_Additional__c!= trigger.oldMap.get(ld.Id).E_Mail_Additional__c)
         
        {
            if ((ld.Email != null && LeadsMap .get(ld.Email) != null) || (ld.E_Mail_Additional__c!= null && LeadsMap .get(ld.E_Mail_Additional__c) != null) )
             {
                ld.adderror('Lead already exist with this  Email. You cannot create a duplicate leads.');
            }
        }

        if ( Trigger.isInsert || (ld.Phone != trigger.oldMap.get(ld.Id).Phone) ||
        (ld.MobilePhone!= trigger.oldMap.get(ld.Id).MobilePhone)||
        (ld.Whatsapp_Mobile__c!= trigger.oldMap.get(ld.Id).Whatsapp_Mobile__c)||
        (ld.Mobile_Additional__c!= trigger.oldMap.get(ld.Id).Mobile_Additional__c)||
        (ld.Phone_Additional__c!= trigger.oldMap.get(ld.Id).Phone_Additional__c))
        {
            if ((ld.Phone != null && LeadsMap.get(ld.Phone) != null) ||
           ( ld.MobilePhone!= null && LeadsMap.get(ld.MobilePhone) != null)||
            (ld.Whatsapp_Mobile__c!= null && LeadsMap.get(ld.Whatsapp_Mobile__c) != null)||
            (ld.Mobile_Additional__c!= null && LeadsMap.get(ld.Mobile_Additional__c) != null)||
            (ld.Phone_Additional__c!= null && LeadsMap.get(ld.Phone_Additional__c) != null)) {
                ld.adderror('Lead already exist with this Phone Number . You cannot create a duplicate leads.');
            }
            setId.add(ld.id);
        }
        
        
        
         if ( (Trigger.isupdate  && (ld.Email!=Null || ld.E_Mail_Additional__c!=Null)) && ((ld.Email != trigger.oldMap.get(ld.Id).Email ) ||
        (ld.E_Mail_Additional__c!= trigger.oldMap.get(ld.Id).E_Mail_Additional__c)))
         
        {
            if ((ld.Email != null && LeadsMap .get(ld.Email) != null) || (ld.E_Mail_Additional__c!= null && LeadsMap .get(ld.E_Mail_Additional__c) != null) )
             {
                ld.adderror('Lead already exist with this  Email. You cannot create a duplicate leads.');
            }
        }

        if ((Trigger.isupdate && (ld.Phone!=Null ||ld.MobilePhone!=Null ||ld.Whatsapp_Mobile__c!=Null || ld.Mobile_Additional__c!=Null ||
     ld.Phone_Additional__c!=Null)) &&  ((ld.Phone != trigger.oldMap.get(ld.Id).Phone) ||
        (ld.MobilePhone!= trigger.oldMap.get(ld.Id).MobilePhone)||
        (ld.Whatsapp_Mobile__c!= trigger.oldMap.get(ld.Id).Whatsapp_Mobile__c)||
        (ld.Mobile_Additional__c!= trigger.oldMap.get(ld.Id).Mobile_Additional__c)||
        (ld.Phone_Additional__c!= trigger.oldMap.get(ld.Id).Phone_Additional__c)))
        {
            if ((ld.Phone != null && LeadsMap.get(ld.Phone) != null) ||
           ( ld.MobilePhone!= null && LeadsMap.get(ld.MobilePhone) != null)||
            (ld.Whatsapp_Mobile__c!= null && LeadsMap.get(ld.Whatsapp_Mobile__c) != null)||
            (ld.Mobile_Additional__c!= null && LeadsMap.get(ld.Mobile_Additional__c) != null)||
            (ld.Phone_Additional__c!= null && LeadsMap.get(ld.Phone_Additional__c) != null)) {
                ld.adderror('Lead already exist with this Phone Number . You cannot create a duplicate leads.');
            }
            
            setId.add(ld.id);
        }
        
    }
    
}
 
Hi,
I have the following code

Opportunity oppty = new Opportunity();
oppty.Name='123';
insert oppty;

Product2 pr = new Product2();
pr.Name = '123';
pr.Description = 'my product';

myJunctionObject obj = new myJunctionObject();
obj.Product2.id  = pr.id; //
obj.Opportunity.id  = oppty.id;
insert obj;

I am getting the error - Attempt to dereference a null object.Null pointer exception at 'insert obj;'
Can anyone suggest a solution to overcome this

Thanks,
Abhilash
Hi all,

I'm trying to add a previously created html email into a visualforce page but I keep getting the error below:

User-added image
Here is the start of my code (which i feel is causing the issue):

<messaging:htmlEmailBody >

<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office"><head>


I've tried adding </link> to line 158/159 but it doesn't make a difference.

Thanks
 
Hi, wonder if anyone could guide me in the right direction. Got the below class but the requirement has changed since and now I need to insert the id's of deleted records into a custom object for tracking purposes before they get deleted. any ideas? Thanks
 
global class BatchDeletion implements Database.Batchable<sObject>, Schedulable{   
    global BatchDeletion(){}

    global Database.QueryLocator start(Database.BatchableContext bc){
        return Database.getQueryLocator([Select id from Case where Archived__c='true']);
    } 

    //Execute method for the Schedulable interface
    global void execute(SchedulableContext sc){   
        //execute the batch
        BatchDeletion deleteCS = new BatchDeletion();
        ID batchprocessid = Database.executeBatch(deleteCS);
    }

    //Execute method for the batchable interface
    global void execute(Database.BatchableContext BC, list<sObject> scope){     
        delete scope;   
        DataBase.emptyRecycleBin(scope); 
    }

    global void finish(Database.BatchableContext BC){}
}

 
  • March 22, 2018
  • Like
  • 0
Dear all,

I am building an Apex Case trigger where each case is linked to an Account field and I can access the c.AccoundId. Having the Id of the account I need to access the "Sales division" field.
 
Case c = Trigger.new[0];

Account accSalesDivistion = [SELECT Id, Sales_Division__c FROM ACCOUNT WHERE Id = c.AccountId];
I'm calling the above query but it's returning me a lot of syntax errors. 
But I'm not sure what's the problem here. 
Can you help? It looks that using c.AccountId it's not possible in the SQL, isn't it? The error message I get is "Unexpected token 'accSalesDivistion'."

Thank you for your help.
GC




 
Hi All,

I need to render a picklist field if other text field is valued. How to check if the field is valued or not? Can someone please help me this.

Thanks In Advance.
  • March 22, 2018
  • Like
  • 0
when i am updating the trigger the contact description is not changing and how to write code for delete trigger for contacts in the same code.....

trigger contactbeforeinsert on Contact (before insert,before update) {
    for(contact c:trigger.new){
         if (c.Description == null)
        {
            c.Description = '(before Contact insert trigger wrote this)';
        }
        else
        {
            c.Description = c.Description + '(before Contact insert trigger wrote this)';
        } 
        for(contact con:trigger.old){
        if (trigger.isBefore) {
        if(trigger.isUpdate)
        {
        contact con1 = [select id , lastname , Description from contact];
            if(con1.Description == null){
        con1.Description = 'New description';
       
        }
             update con; 
        }
            
    }
    }
}
}
I have 5 mobile fields in lead object
To avoid the lead duplicate I have to check all the 5 fields with each other

This my code is trying to check the duplicates. Is the correct way to check the duplicates?

Trigger leadduplicatecheck on lead(before insert,Before Update)
{

List<Lead> llist=new list<lead>();

Set<string> setMobilePhone =new set<String>();
Set<string> setWhatsapp =new set<String>();
Set<string> setMobile =new set<String>();
Set<string> setPhone     =new set<String>();
Set<string> setPhoneAdd =new set<String>();

for(Lead l:Trigger.new)
{
setMobilePhone.add(l.MobilePhone);
setWhatsapp.add.(l.Whatsapp_Mobile__c);
setMobile.add.(l.Mobile_Additional__c);
setPhone.add.(l.Phone);
setPhoneAdd.add.(l.Phone_Additional__c);

}

llist=[select ID from Lead where (MobilePhone =:setMobilePhone or MobilePhone=:setWhatsapp
MobilePhone =:setMobile or
MobilePhone =:setPhone or
MobilePhone =:setPhoneAdd  ) OR

(Phone =:setMobilePhone or
 Phone=:setWhatsapp or
Phone =:setPhone or
Phone =:setMobile or
Phone =:setPhoneAdd ) OR


(Mobile_Additional__c =:setMobilePhone or
 Mobile_Additional__c=:setWhatsapp or
Mobile_Additional__c =:setPhone or
Mobile_Additional__c =:setMobile or
Mobile_Additional__c =:setPhoneAdd ) OR

(Whatsapp_Mobile__c =:setMobilePhone or
 Whatsapp_Mobile__c=:setWhatsapp or
Whatsapp_Mobile__c =:setPhone or
Whatsapp_Mobile__c =:setMobile or
Whatsapp_Mobile__c =:setPhoneAdd ) OR

(Phone_Additional__c =:setMobilePhone or
 Phone_Additional__c=:setWhatsapp or
Phone_Additional__c =:setPhone or
Phone_Additional__c =:setMobile or
Phone_Additional__c =:setPhoneAdd )];



For(Lead l : Trigger.New)
{
if(Trigger.isupdate &&llist.size()>0)
{
l.adderror('Already Lead Exist with this Mobile Nuber, Duplicate');

}

if(Trigger.insert  && llist.size()>0)
{
l.adderror('Already Lead Exist with this Mobile Nuber');

}
}   
}


 
Hi All,

I am working on a PoC where i am consuming data from an external servcie and displaying it on a VF page.
Can someone let me know where i am going wrong and what needs to be done to display the data on the VF page.
public class TickerData {
	
	public list<Prices> pricelist{get;set;}
    private static String endpoint='https://koinex.in/api/ticker';
    
    public list<Prices> getmakeTickerData(){
		
		
		pricelist = new list<Prices>();
        Http http= new Http();
        HttpRequest request= new HttpRequest();
        request.setendpoint(endpoint);
        request.setMethod('GET');
        HttpResponse response = http.send(request); //response contains json body
        
        if(response.getStatusCode()==200){
            system.debug('Response'+response.getBody());
            //JSON2Apex js=JSON2Apex.parse(response.getBody());
            JSONParser parser = JSON.createParser (response.getBody()); 
   			while (parser.nextToken()!=null) { 
                if (parser.getCurrentToken()== JSONToken.START_ARRAY) {    
                    while (parser.nextToken()!= null) { 
                        
                        //
			if(response.getstatusCode() == 200 && response.getbody() != null){

				pricelist=(List<Prices>)json.deserialize(response.getbody(),List<Prices>.class);

			}//
                        /*if (parser.getCurrentToken()== JSONToken.START_OBJECT) { 
                            JSON2Apex the = (JSON2Apex) parser.readValueAs (JSON2Apex.class); 
                        }*/
                  }
            }
			
			
            //Map<String,Object> results=(Map<String,Object>)JSON.deserializeUntyped(response.getBody());
            /*List<Object> prices=(List<Object>)results.get('prices');
            
            for(Object o:prices){
                System.debug('Prices :'+o);
                
            }*/
        	}
        
    	}
        return pricelist;
	}


	public class Prices {
		public String BTC{get;set;}
		public String ETH{get;set;}
		public String XRP{get;set;}
		public String BCH{get;set;}
		public String LTC{get;set;}
		public String NEO{get;set;}
		public Double MIOTA{get;set;}
		public String TRX{get;set;}
		public String OMG{get;set;}
		public String AE{get;set;}
		public String ZRX{get;set;}
		public String GAS{get;set;}
		public String BAT{get;set;}
		public String GNT{get;set;}
		public String REQ{get;set;}
		public String AION{get;set;}
		public String NCASH{get;set;}
		public String XLM{get;set;}
	}
	
    public class JSON2Apex {
		public Prices prices;
		public Stats stats;
	}
    
	public Prices prices;
	public Stats stats;

	public class ETH {
		public String currency_full_form;
		public String currency_short_form;
		public String per_change;
		public Double last_traded_price;
		public String lowest_ask;
		public String highest_bid;
		public String min_24hrs;
		public String max_24hrs;
		public Integer vol_24hrs;
	}

	public class Stats {
		public ETH ETH;
		public ETH BTC;
		public ETH LTC;
		public ETH XRP;
		public ETH BCH;
		public ETH OMG;
		public ETH REQ;
		public ETH ZRX;
		public ETH GNT;
		public ETH BAT;
		public ETH AE;
		public ETH TRX;
		public ETH XLM;
		public ETH NEO;
		public ETH GAS;
		public ETH NCASH;
		public ETH AION;
	}

}
 
VF Page :

<apex:page controller="TickerData">
<apex:form>

<apex:pageBlock >

<apex:pageBlockTable value="{!makeTickerData}" var="wrap" width="100%">
<apex:column headerValue="BTC" value="{!wrap.BTC}"/>
<apex:column headerValue="ETH" value="{!wrap.ETH}"/>
</apex:pageBlockTable>

</apex:pageBlock>
    
</apex:form>
</apex:page>

 
Hi Guys- I have an custom object "Address__c" related to Account, when passing the account id there I am not getting any records, please suggest

public with sharing class DisplayQueryList{ 
    public List<Address__c> Records {get; set;} 
    public DisplayQueryList(){ 
    Records = [select Id,Name FROM Address__c WHERE Id = :ApexPages.currentPage().getParameters().get('id')];
    system.debug('record-->'+Records); 
    } 
     
}
Hello,
Which is best practice from memory allocation view of point , if I have to show three or four fields on visualforce page :
1. 
public MyCustomObject__c oMyCustomObject{get;set;}

or.

2.
public String sNotes{get;set;}
public String sStatus{get;set;}
public datetime dClosedDate{get;set;}
Hello,

insert cloneQuoteList; 

I am inserting the list of quote.
How can i get the Opportunity Id and Inserted qute id after the insert.

I want to use the Ids to insert the cloned quote line items

thank you
Hello,

I'm getting the error below.

Error: Compile Error: Constructor not defined: [ApexPages.StandardSetController].<Constructor>(Login_Information_Object__c) at line 22 column 46

for the Test Class below. The Test Class is for a Visualforce Page controller. Any assistance is greatly appreciated.
 
@isTest
public class VFTSIAITSplashPageController_UT {

    
    static testMethod void myTest() {
        Login_Information_Object__c lio=new Login_Information_Object__c();
       
        lio.LIO_Content__c='test';
        lio.LIO_End_Date__c=Date.today() + 30;
        lio.LIO_Start_Date__c=Date.today() + 1;
        lio.Show_On_Login__c=TRUE;
        lio.Subject__c='testing';
        insert lio;   
        
        PageReference pageRef1 = Page.TSIAInformationSplashPage;
        Test.setCurrentPage(pageRef1);
        pageRef1.getParameters().put('id',lio.Id);

        ApexPages.StandardSetController sc = new ApexPages.StandardSetController(lio);
        VFTSIAITSplashPageController testlio = new VFTSIAITSplashPageController (sc);
        
        testlio.save();    
 
        
        
    }
}

 
  • June 12, 2019
  • Like
  • 0
I have three batch classes, I want to execute all three batch classes through button click using visualforce page at the same time.
LoanofficerBatch lob = new LoanofficerBatch(); 
        database.executebatch(lob);
        
        RealtorBatch rb = new RealtorBatch(); 
        database.executebatch(rb);
        
        BuilderBatch bb = new BuilderBatch(); 
        database.executebatch(bb);

please help
trigger trg4 on Account (after insert) 
{
    Map<Id,Decimal> map1 = new Map<Id,Decimal>();
    for(Account a : trigger.new)
    {
        map1.put(a.id, a.No_of_Contacts__c);
    }
    
    
   List<Contact> con = new List<Contact>();
    if(trigger.isinsert && trigger.isafter)
    {
        if(map1.size() > 0 && map1 !=null)
        {
            for(Id a: map1.keySet())
            {
                for(integer i=1;i<=map1.get(a) ; i++)
                {
                    Contact c = new Contact();
                    c.LastName='Demo Contact';
                    c.AccountId=a;
                    c.Phone='454646';  
                    con.add(c);
                }
            }
        }
        INSERT con;
    }
}


Errors:
Variable does not exist: LastName
Variable does not exist: AccountId
Variable does not exist: Phone
DML requires SObject or SObject list type: List


Kindly help me to solve this problem in trigger.
Hi Guys, need Test class for the below Code  Snippet.please help :

trigger AccountContractTrigger on AccountContract__c (after insert, after delete) {
    List<AccountContract__c> targetList;
    if(Trigger.isInsert) {
        targetList = Trigger.new;
    } else if(Trigger.isDelete) {
        targetList = Trigger.old;
    }
    Set<Id> parentIds = new Set<Id>();
    for(AccountContract__c rec: targetList) {
        parentIds.add(rec.Contract__c);
    }
    List<ContractSheet__c> parentList = [SELECT Id, ContractPartner__c, (SELECT Account__r.Name FROM AccountChild__r) FROM ContractSheet__c WHERE Id IN: parentIds];
    system.debug('names is'+parentList);
    for(ContractSheet__c parent : parentList) {
        String names = '';
        for(AccountContract__c nameSource: parent.AccountChild__r) {
            names += nameSource.Account__r.Name + ', ';
        }
        names = names.removeEnd(', ');
        parent.ContractPartner__c = names;
        system.debug('names is'+parent.ContractPartner__c);
    }
    update parentList;
}

 
Hi guys,


I'm getting "Dependent class in invalid and needs recompilation" error on my test class. Can you please tell me why I'm receving this error?
  • August 07, 2018
  • Like
  • 0
hi everyone,
could anyone please explain me how to perform actions like(insert,update etc) when the vf page is loaded.



Thanks

Hi all,

I'm making a custom Rest API and having some problems with endpoints mapping.
I had a class named RestResource_Opportunities, with mapping @RestResource(urlMapping='/contas/*/oportunidades');
And a class named RestResource_OpportunityId, with mapping  @RestResource(urlMapping='/contas/*/oportunidades/*').

When I compile the Opportunities class, the both endpoints maps to OpportunityId class.
When I compile the OpportunityId class, the both endpoints maps to Opportunities class.

This behavior also happens with /contas/*/contatos and /contas/*/contatos/* endpoints.

I don't know why this happens, since the mappings are differents... Anyone can help?

Hi,

I want to write a trigger, which throws error message , when the accountname is changed from the cloned version of record.

I have tried writting code, somehow its not working

Can someone help

Please find the code below : 

trigger PreventChangeOfAccountName on Order (before update , after insert) {
    
    for (Order o : trigger.new){
        
       If  (o.isClone() && trigger.oldmap.get(o.Id).AccountId <> trigger.oldmap.get(o.Id).AccountId)
       {
           o.addError('Account Name for Cloned records cant be changed');
       }
    }
}  
Hi,

I created an apex class that creates a task. Im wondering how I can change that to 'Log a Call'. The reason I want to do this is because in our feed view in cases there is a 'Log a Call' section and a 'Task and Activity' section. I want to populate the Log section rather than the Task section. 

Thanks,
-Julio Hernandez
I need to understand the differences between 'Log A Call' and 'New Task'.

When I do 'Log A Call' it actually creates a 'Task' record.
When I do 'New Task' it also creates a 'Task' record.

When on a case screen and I click 'Tasks and Events' I see only the item I created as 'New Task. When I click on 'Call Logs' I see only the item I created as 'Log A Call'.

Both of these items are actual task records but they are different in some way such that they only show on their respective lists when selecting Call Logs or Tasks and Events.

So, I used a SOQL statement to show me all task records for a case and of course, I get both records. Life is good. My question is, which field in the task record differentiates one as a call log and the other as a task. I've printed all the fields and their values and the 2 records appear to be identical with the exception of the Subject and Description/Comment.

Any ideas how to determine the differences, or more importantly, I'm using a C# WSDL service to write records and I would like to know how to insert one task as a task and one task as a call log.

Thanks.
  • March 18, 2014
  • Like
  • 0

Have created a few custom fields against Opportunity.

AgencyAccount -> Link to Account record (only accounts deemed as 'agents')
AgencyContact -> Link to contact (only contacts from accounts deemed to be 'agents')

and a couple other date and status fields

all of them work fine except for AgencyContact?

i include it in my SOQL query and it just won't come through - but it doesnt give me an unknown field error either - the results as an array look like this:
stdClass Object ( [Id] => 0067F00000AGqRiQAL [AgencyAccount__c] => 0017F00000MPAwtQAH [AgencyBooking__c] => 1 [AgencyDiscount__c] => 10 [Amount] => 3300 [Campaign] => stdClass Object ( [Id] => [Name] => APGA 50th Anniversary Publication ) [CloseDate] => 2018-03-30 [Contact__c] => 0037F00000K8iH4QAJ [Name] => TAP [OpportunityLineItems] => stdClass Object ( [done] => 1 [queryLocator] => [records] => Array ( [0] => stdClass Object ( [Id] => [CurrencyIsoCode] => AUD [Description] => ERHP [ListPrice] => 3300 [Name] => TAP Early Right Hand Full Page [PricebookEntry] => stdClass Object ( [Id] => [Product2Id] => 01t7F000002rW2mQAE ) [Product2] => stdClass Object ( [Id] => [Name] => Early Right Hand Full Page ) [TotalPrice] => 3300 [UnitPrice] => 3300 ) ) [size] => 1 ) [Owner] => stdClass Object ( [Id] => [Name] => Dave Marsh ) ) SObject Object ( [type] => [fields] => )


query:
Select Id,Contact__c,Amount,CloseDate,Name,Campaign.Name,Owner.Name,AgencyBooking__c,AgencyContact__c,AgencyAccount__c,AgencyDiscount__c,(Select PricebookEntry.Product2Id,TotalPrice,UnitPrice,ListPrice,CurrencyIsoCode,Name,Description,Product2.Name From OpportunityLineItems) From Opportunity WHERE AccountID = '##salesforce_id##' AND StageName='Closed Won' AND Booking_Status__c = NULL

ready for the really weird part?

when i do the same query in the free soql builder app

(https://soqlbuilder.herokuapp.com/)

i get the field data!!!
User-added image

driving me absolutely nuts!!

happy to provde any more code or anything if anyone has questions, but i have run several queries before with no issues

i updated the WSDL file too and in it, the custom field is defined and everything!!
 

The organization owner received a developer script exception via email from the production. Please note that I have not access to the production, the owner deployed the change set.

There is a /JSON/ REST integration with an Apex class to receive POST callouts via a Site Guest User. The method throws an Exception (Upsert failed, DUPLICATE_VALUE) and this is correct. A value duplicated in a unique field.

The problem is something else: The full method body is in a try-catch. The line (line 82) that causes the exception is in the try block. Why received the owner the developer script exception email? The salesforce send developer script exception email from handled exception?

Subject: Developer script exception from Természetesen Alapítvány : AccountForContactCreation : AccountForContactCreation: execution of BeforeInsert caused by: System.DmlException: Upsert failed. First exception on row 102; first error: DUPLICATE_VALUE, Duplicate external id specified: XXXXXXXXXXXXXXX: [A_NameExternalId__c] Trigger.AccountForContactCreation: line 82, column 1
To: "info@XXXXXXXXXX.com" <info@XXXXXXXXXX.com>


Apex script unhandled trigger exception by user/organization: 0050O00000XXXX/00D2000000XXXXX

AccountForContactCreation: execution of BeforeInsert

caused by: System.DmlException: Upsert failed. First exception on row 102; first error: DUPLICATE_VALUE, Duplicate external id specified: XXXXXXXXXXXXXXX: [A_NameExternalId__c]

Trigger.AccountForContactCreation: line 82, column 1

Thanks in advance,
Krisztian