• Ahmad J. Koubeissy
  • NEWBIE
  • 374 Points
  • Member since 2016
  • Salesforce Consultant
  • EI-Technologies


  • Chatter
    Feed
  • 11
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 0
    Questions
  • 98
    Replies
I have created a custom object and am needing to now create a custom related list inside of that object. I know i have to relate it with master-detail or lookup relationships but i don't know how to actually create a new related list to even have the option of relating it. The standard salesforce list of "log a call" is basically what i need under my new object but i need it to be for new features. I have the log a call related list in my object but i need a way of cloning or knowing how to create a new one. Can anyone share best practices?
Hi Guys, I'm currently experiencing the following issue in my org when deploying Custom Settings from the Development environment to the Production environment. The values are available in both the Development and UAT environments but when we deploy to Production only the custom settings (labels and descriptions) are coming through, the acual values existing in the DEV and UAT environments are being excluded.
All the related Apex classes and Apex triggers as well as Profile Settings have been checked and there are no differences between DEV and PROD.
How do we add these values while deploying?
 
Hi,

I am getting the following error on my apex class

Error: Compile Error: unexpected syntax: 'mismatched input ',' expecting MAPPED_TO' at line 18 column 11


Help me how to fix it

Thanks in Advance
MY APEX CLASS :


public class overlapDateHandler{

    public void overlapDateMethod(list<contract> contractList){
    
        set<Id> accountIdSet = new set<Id>();
        list<Account> accList = new List<Account>();
        map<integer, integer> dateMap = new map<integer, integer>{
        1 => 31, 
        3 => 31, 
        4 =>30, 
        5 =>31, 
        6 => 30, 
        7 => 31, 
        8 => 31, 
        9 =>30, 
        10 =>31, 
        11 =>30, 
        12, 31, };
        map<id, list<Contract>> idVsContractmap = new map<id, list<contract>>();
        list<Contract> updateContractList = new list<Contract>();
        for(Contract conObj : contractList){
            
            if(conObj.AccountId  != null){
                
                accountIdSet.add(conObj.AccountId);
            }
        }
        accList = [Select Id, (Select startdate__c, enddate__c, AccountId From Contracts) From Account Where Id IN :accountIdSet]
        for(Account accObj : accList){
            
            idVsContractmap.put(accObj.id, accObj.Contracts);
        }
        for(Contract conObj : contractList){
            
            if(conObj.AccountId != null){
            
                if(idVsContractmap.containsKey(conObj.AccountId)){
                    
                    for(Contract contractObj : idVsContractmap.get(conObj.AccountId)){
                        
                        if(contractObj.enddate__c.month() == conObj.startdate__c.month()){
                            
                            if(contractObj.enddate__c.month() - 1 == 2){
                            
                                if(MOD( contractObj.enddate__c.year()) + 1, 4) = 0){
                                    
                                    string newDate = 29 +'//'+contractObj.enddate__c.month() - 1+'//'+contractObj.enddate__c.year();
                                    contractObj.enddate__c =  date.parse(newDate);
                                }
                                else{
                                    
                                    string newDate = 28 +'//'+contractObj.enddate__c.month() - 1+'//'+contractObj.enddate__c.year();
                                    contractObj.enddate__c =  date.parse(newDate);
                                }
                            }
                            else if(contractObj.enddate__c.month() - 1 == 0){
                                
                                string newDate = 31 +'//'+12+'//'+contractObj.enddate__c.year() -1;
                                contractObj.enddate__c =  date.parse(newDate);
                            }
                            else{
                                
                                string newDate = 31 +'//'+dateMap.get(contractObj.enddate__c.month() - 1)+'//'+contractObj.enddate__c.year() -1;
                                contractObj.enddate__c =  date.parse(newDate);
                            }
                        }
                        updateContractList.add(contractObj);
                    }
                }
            }
        }
        update updateContractList;
    }
}

 
help me to write trigger if date is less than or equal to 10 , i need to upate previous month last date . if it is above 10 we need to update same day

ex: date : 04-Jun-17   output -- 31-may-17
ex: date  : 10-jun-17  output -- 31-may-17
ex: date   11-jun-17    output -- 11-jun-17

i tried this formula
IF(MONTH(Date__c) < 12,
IF(DAY(Date__c) > 10, Date__c, DATE(YEAR(Date__c), MONTH(Date__c)-1,30)),
IF(DAY(Date__c) > 10, Date__c, DATE(YEAR(Date__c) + 1, 1, 30)))

if input is 02-06-17 ,but iam getting output as  01-05-17   i need to be 31-05-17.
Hi All
Is there any way to block (non editable )all existing record of one custom object after some specific date.
 I have 3 objects   expense report, Region and Resource and all have lookup fields need to update using trigger.
 
 1. Expesene report has fields
 
    Expense Report Name :
    Region                :
    Company                 :
 
 2. Region object has fields
    Region Name:
    Resource   :
 
 3. Resource object has fields
    Resource Name :
    Company       :
    
    
 I need to write trigger that when expense report has created need to update company name automatically from (Expesene_report__r.Region__r.Resource__r.Company__c
 
  1. Expesene report has fields
 
    Expense Report Name :  Travel to company
    Region                :  England
    Company                :
 
 2. Region object has fields
    Region Name:  England
    Resource   :    Rajeev
 
 3. Resource object has fields
    Resource Name :    Rajeev
    Company       : Sunny Industries
    
    
    If Expense report (Travel to comapny ) is saved i need to update company as (Sunny Industries ) automatically..
I was kindly shown how to have a checkbox ticked if the created day or a record was the previous working day (not including weekends), I would now like to adapt this so the checkbox is ticked if the created date is greater or equal to the last working day (not including weekends) but less than today.

The previous post is here:

https://developer.salesforce.com/forums/ForumsMain?id=9060G000000BcNo

Thanks in advance.

Hi, I'm trying to get a checkbox ticked where the created date is yesterday except for on a Monday where it would need to be the previous Friday, any help appreciated.
 

Regards,

Pete

I created one Close Task checkbox in Account. Whenever I checked on Close Task in Account, all task should be closed.
I'm learning how to write triggers. I wrote a trigger but it's not working. Please look at it and help.
 
trigger CloseTaskInAccount on Account (before update) {
    List<Account> acc = [Select Id From Account];
    for(Account acc : Trigger.new) {
        Task t = new Task();
        if(acc.Close_Task__c == True) {
            t.Status = 'Completed';
            t.WhatId = acc.Id;
            update t;
        }
    }
}
I wrote an apex trigger that connected two of my objects (Contacts and Voter File-custom object) via a look up field if they had the same first name, last name, and zipcode. 

I was able to succesfully to this however, once I deployed to production I found out that my query was to large as I was trying to match across 15 million records or so. 

After looking into I found out that I had to write an apex Batch class in order to have this work succesfully with my 15 million plus records, however now I am stuck.

I tried looking up some articles but I am not really sure what way to go such as if I have to start all over or just write the batch class based off the trigger I already wrote. 

The trigger is below if you guys could help me with this I would be able to write the classes for my other triggers. 

Thanks. 
 
trigger Contact2VoterID on Contact (before insert,before update,after insert,after update) 
{
{
    Set<String> set_Str = new Set<string>();
    Map<String,Voter_File_TX__c> mp_VoterFile;
    
    if(Trigger.isAfter && Trigger.isUpdate)
    {
        for(Voter_File_TX__c VoterFile : [Select ID,First_Name__c, Last_Name__c,Zipcode__c, Contact__c From Voter_File_TX__c])
        {
                    if(mp_VoterFile==null)
                        mp_VoterFile = new Map<String,Voter_File_TX__c>();
            
            mp_VoterFile.put(VoterFile.First_Name__c +''+VoterFile.Last_Name__c +''+VoterFile.Zipcode__c,VoterFile);

 
                    }
        
        for(Contact ContactList : Trigger.new)
    {
        if(mp_VoterFile!=null && mp_VoterFile.containsKey(ContactList.FirstName+''+ ContactList.LastName+''+ ContactList.MailingPostalCode))

        {

       mp_VoterFile.get(ContactList.FirstName +''+ ContactList.LastName +''+ ContactList.MailingPostalCode).Contact__c = ContactList.id;

}

}
 
if(mp_VoterFile!=null && mp_VoterFile.values()!=null)
        update mp_VoterFile.values();

    }
}
}



 
I created identical formula fields on the Lead and Contact. But when I try to map them together the Contact version of the field is not available in the picklist. This is my first time creating a formula field. Is it not possible to map Lead and Contact formula fields together?
Hi,

We have apex code, API and batch class to create the custom object record and generate the attachment. since apex code is running in system mode. we want to give user only read permission on this custom object. but found out when the code trying to create an attachment for the record, got error. when user has edit permission on the object, creating attachment code is working. But shouldn't system mode care the object and field level permission at all?
Hi there,

I am a newbie here and dont have much expierience with codes, triggers or visualforce.  I am okay with Process Builder and a bit on Validation Rule and Workflow Rules.

In my opporunity page I have a picklist called "Market" and it has dependent field called "Sub-Market". The "Sub Market" picklist has in turn also has a dependent field called "Application".
So depending on what users selects in "Market" - it will show few picklists selection for "Sub-Market" and similarly for "Application" .
Now my team wants to move this "Application" picklist from Opporunity to a related custom object. 
How can I keep the link and depencies? 









 
I have created a custom object and am needing to now create a custom related list inside of that object. I know i have to relate it with master-detail or lookup relationships but i don't know how to actually create a new related list to even have the option of relating it. The standard salesforce list of "log a call" is basically what i need under my new object but i need it to be for new features. I have the log a call related list in my object but i need a way of cloning or knowing how to create a new one. Can anyone share best practices?
I have an approval process in Oportunities object, that requires to be approved by the user configured in accounts (look up field ), which would come to be the Comersial Manager. this manager may be different for each account record.

Is there some way to put that user in fine as approver.
 repeat .. I can not put an espesific user in the process builder because the manager can be variable with each account and I can not put it in a queue, because the Aproval Process has to be aprove by Comersial Mnager.


I have tried to do it by configuration but I do not see how to do it, the way I see more possible to do is with a formula that obtains that field (user) and place it in opportunities, but I do not know how to assign it as approver.

I have no idea how to do it by code so I contact you mainly to see if it is possible to do this by code.

User-added image

Best regards
I am trying to create a new field for address in the Opportunity section.  I'd like the address to auto populate from the Account section.  I'm having trouble getting them to link.  I did the following: User-added imageUser-added imageUser-added image
How to make parent field mandatory before create child record..
Trying below code but getting error :
Apex trigger oppsplicreate caused an unexpected exception, contact your administrator: oppsplicreate: execution of AfterInsert caused by: System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, oppsplicreate: maximum trigger depth exceeded Opportunity_Splits trigger event AfterInsert
  1.  Whenever an opportunity is created an opportunity split record should be created with the practice same as that of opportunity and percentage as 100. (If the practice is one)
  2. If there are two practices then whenever an opportunity is created two opportunity split records should be created with the practices same as that of opportunity and each with 50% share

Sum of the two should always be equal to 100%

trigger oppsplicreate on Opportunity_Splits__c(after delete, after insert, after update){

    set<Id> OpportunityIds = new set<Id>();
    List<Opportunity_Splits__c> opportunitySplitList = new List<Opportunity_Splits__c>();
    
    
    if(trigger.isInsert || trigger.isUpdate)
    {
        for(Opportunity_Splits__c p : trigger.new)
        {
            OpportunityIds.add(p.Opportunity__c);    
            opportunitySplitList.add(p);
            system.debug('-----opportunitySplitList--------'+opportunitySplitList);
        }
    }     
    List<Opportunity_Splits__c> lstCon = new List<Opportunity_Splits__c>();
    Opportunity oppt= [Select Id, Practiceu__c FROM Opportunity WHERE  id IN :OpportunityIds];
//    Opportunity oppt=[SELECT Name from Opportunity where Practiceu__cIN :multselect.split(';')
    system.debug('-----oppt--------'+oppt);
    String str = oppt.Practiceu__c ;
    system.debug('-----str --------'+str );
    if(str !=null)
    {
        List<String> lstValues = str.split(';');
        for(String pkValue: lstValues)
        {
            Opportunity_Splits__c con = new Opportunity_Splits__c(Opportunity__c = oppt.Id, Practice__c =pkValue);
            lstCon.add(con);    
        }
        insert lstCon;
}
}

I want to delete the records which one year older 
I have a custom object and using dataloader records get loaded. on create i have a trigger that does some processing and creates/update product2 records. Most of the times trigger runs successfully but sometimes i get the following error:
RawAircraftTrigger: execution of AfterInsert

caused by: System.UnexpectedException: common.exception.SfdcSqlException: Invalid column index

Class.RawAircraftsTriggerHandler.loadCrafts: line 58, column 1
Trigger.RawAircraftTrigger: line 3, column 1

My line 58 starts as follows
for(Account a : [Select id, Name, Account_Name_2__c from Account where Name in :accountKeys OR
                         Account_Name_2__c in :accountKeys])
{
    existingaccounts.put(a.Name, a);
    existingaccounts.put(a.Account_Name_2__c, a);
}

I am clueless what could be the main issue here.
Hello,

I want to make picklist field read only. There is no permission set. I make it read only from page layout, Field level security and profile too. Still its read only. What will be another option to make it rad only?

Thanks & Reagrds,
Utkarsha
Hi Guys, I'm currently experiencing the following issue in my org when deploying Custom Settings from the Development environment to the Production environment. The values are available in both the Development and UAT environments but when we deploy to Production only the custom settings (labels and descriptions) are coming through, the acual values existing in the DEV and UAT environments are being excluded.
All the related Apex classes and Apex triggers as well as Profile Settings have been checked and there are no differences between DEV and PROD.
How do we add these values while deploying?
 
Hello everyone,

I am seeking to know about is there any way to skip client's validations rules by programatically ..?

Thanks in advance..!
Hello,

I want to add Validation on account object when upserting new records. Please suggest how it can be done.

First, I want to check whether that record exists using "key" field(unique).If it exists, and the record has different email than what we have in our record; the system should throw an error with some message.

Second, I want to do same validation as in step 1, but this time with email. When upserting, if the record has same email and different key than what we have in our existing record; the system should not allow the upsert.
 I have 3 objects   expense report, Region and Resource and all have lookup fields need to update using trigger.
 
 1. Expesene report has fields
 
    Expense Report Name :
    Region                :
    Company                 :
 
 2. Region object has fields
    Region Name:
    Resource   :
 
 3. Resource object has fields
    Resource Name :
    Company       :
    
    
 I need to write trigger that when expense report has created need to update company name automatically from (Expesene_report__r.Region__r.Resource__r.Company__c
 
  1. Expesene report has fields
 
    Expense Report Name :  Travel to company
    Region                :  England
    Company                :
 
 2. Region object has fields
    Region Name:  England
    Resource   :    Rajeev
 
 3. Resource object has fields
    Resource Name :    Rajeev
    Company       : Sunny Industries
    
    
    If Expense report (Travel to comapny ) is saved i need to update company as (Sunny Industries ) automatically..