• karthikeyan perumal
  • PRO
  • 3181 Points
  • Member since 2015

  • Chatter
    Feed
  • 89
    Best Answers
  • 0
    Likes Received
  • 2
    Likes Given
  • 1
    Questions
  • 543
    Replies
Hello,
I have a batch job which runs to populate two objects.. Monthly Activity(MonAct) and URL Individual monthly Activity (URLIndMonAct)...
The problem with the response is that I am quering for MonAct records and I am getting back 5 of them . And each of those MonAct records contains with it thousands of URLIndMonAct records...

I have limited my query to just 2 records per batch but I am still getting DML Rows : 10001 error ..
If I redice the size to 1 record, the batch is running for too long...

Can any one please guide me, how can I modify my code to prevent this error and not lose any records while processing...
Any help is appreciated.

Thanks!
global class BatchToUpdateGARecords implements Database.Batchable<sObject>, Database.Stateful, Schedulable, Database.AllowsCallouts{

    private List<String> EMAIL_BATCH_RESULTS = new List<String>{System.Label.Email_List};  
    global  IndividualMonthlyGARecords.BatchResponse runningBatchResponse;
    private String query;
    private Integer queryYear;
    private Integer queryMonth;

    global BatchToUpdateGARecords(Integer year, Integer month){
        runningBatchResponse = new IndividualMonthlyGARecords.BatchResponse();

        // Validate user input, if request to run batch is not for todays date
        if(month != null && year != null && month >= 0 && month <= 12 && year > 1950){
            this.queryYear  = year;
            this.queryMonth = month;
        }
        else{
            Date yesterdaysDate = Date.today().addDays(-1);

            this.queryYear  = yesterdaysDate.year();
            this.queryMonth = yesterdaysDate.month();
        }

        this.query  = 'SELECT Id, GID__c ';
        this.query += 'FROM Monthly_Activity__c ';
        this.query += 'WHERE Year__c = ' + queryYear + ' ';
        this.query += 'AND Month__c = ' + queryMonth + ' ';
        this.query += 'AND GID__c <> null ';
        this.query += 'AND GID__c > 0 ';
        
    }

    global BatchToUpdateGARecords(){
        this(null, null);
    }
    
    global Database.QueryLocator start(Database.BatchableContext BC){
        return Database.getQueryLocator(query);
    }

    global void execute(Database.BatchableContext BC, List<Monthly_Activity__c> currentBatchRecords){
	
        List<Monthly_Activity__c> MonthlyActivities = [
            SELECT Id, GID__c, Month__c, Year__c
            FROM Monthly_Activity__c 
            WHERE Year__c =: queryYear
            AND Month__c =: queryMonth
            AND GID__c IN: Pluck.decimals('GID__c', currentBatchRecords)
        ];        

        List<URL_Individual_Monthly_Activity__c> urlIndividualMonthlyActivities = [
            SELECT Id, GID__c, URL__c, Month__c, Year__c
            FROM URL_Individual_Monthly_Activity__c 
            WHERE Year__c =: queryYear
            AND Month__c =: queryMonth
            AND GID__c IN: Pluck.decimals('GID__c', currentBatchRecords)
        ];        
         
        if(MonthlyActivities.isEmpty()){
            return;
        }
    
        try{           
            IndividualMonthlyGARecords.batchHandlerToUpdateRecords(
                runningBatchResponse,
                MonthlyActivities,
                urlIndividualMonthlyActivities,
                queryYear,
                queryMonth
            );
        
       }catch(exception ex){
            system.debug('exception call :'+ ex.getMessage());
            system.debug('exception call line :'+ ex.getStackTraceString());
        }
        if(runningBatchResponse != null && !runningBatchResponse.getSuccessRecords().isEmpty()){
            List<Database.SaveResult> updateResults =
                Database.update(runningBatchResponse.getSuccessRecords(), false);

            for(Database.SaveResult updateResult : updateResults){
              if(!updateResult.isSuccess()){
                for(Database.Error err : updateResult.getErrors()){
                  runningBatchResponse.addDatabaseError(err.getMessage());
                }
              }
            }
        }

        runningBatchResponse.clearSuccessRecords();
    
        if(runningBatchResponse != null && !runningBatchResponse.getSuccessRecordsIMA().isEmpty()){

            List<Database.SaveResult> updateResults1 =
                Database.update(runningBatchResponse.getSuccessRecordsIMA(), false);

            for(Database.SaveResult updateResult1 : updateResults1){
              if(!updateResult1.isSuccess()){
                for(Database.Error err : updateResult1.getErrors()){
                  runningBatchResponse.addDatabaseError(err.getMessage());
                }
              }
            }
        }

        runningBatchResponse.clearSuccessRecords();
  
    }

    global void execute(SchedulableContext SC){
        Database.executeBatch(new BatchToUpdateGARecords(), 2);                            //Changed from 5    }
    
    global void finish(Database.BatchableContext BC){
        AsyncApexJob apexBatchResult = [
            SELECT Id, Status, NumberOfErrors, JobItemsProcessed, TotalJobItems, CreatedBy.Email
            FROM AsyncApexJob
            WHERE Id =: BC.getJobId()
        ];
    
        // Generate email body
        String emailBody = 'Apex Batch to Update PageviewSessions processed '
            + apexBatchResult.TotalJobItems + ' batches with '+ apexBatchResult.NumberOfErrors + ' failures.\n\n'
            + 'Database errors (if any): ' + JSON.serialize(runningBatchResponse.getDatabaseErrors()) + '\n';
        
        // Extract error string from batch response
        //emailBody += runningBatchResponse.generateErrorString();

        // Send email
        Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
        mail.setToAddresses(EMAIL_BATCH_RESULTS);
        mail.setSenderDisplayName('About.com Experts - Batch Results');
        mail.setSubject('About.com - Batch to Update PageviewSessions - status: ' + apexBatchResult.Status);
        mail.setPlainTextBody('Batch Process has completed\n\n' + emailBody);

        Messaging.sendEmail(new List<Messaging.SingleEmailMessage>{mail});
    }
}

 
I am trying to write a trigger on my Lead Object that will not allow a user to click Convert unless a boolean field is True. I need help with some sample code to get started. 

I plan to create an Approval Process on the lead record, then with the final Approver action have a field update to have my custom checkbox (Approved) set to True. 

Once this happens I want the user to be able to click Convert, but only once the checkbox is set to true. If it has not gone through the approval process, the user shoudnt be able to click convert. 

I should also note I would only want this for a specific record type of my lead object.
Can you send data (via SOAP) out from Sandbox to another System (not Salesforce)?
#newbie
Do requests with the If-None-Match header, that return a 304 response, count towards my API limit?
So I have an issue with a flow.  When I did a test it worked but now its not and I have no idea why.  The error message makes very little sense to me but appears to be an issue with the student field?

Can anyone help me with this:
Error element myRule_1_A1 (FlowRecordCreate).
This error occurred when the flow tried to create records: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY: Meal_Transaction_AIAIAD: execution of BeforeInsert caused by: System.ListException: List index out of bounds: 0 Trigger.Meal_Transaction_AIAIAD: line 24, column 1. For details, see API Exceptions.
This report lists the elements that the flow interview executed. The report is a beta feature.
We welcome your feedback on IdeaExchange.
Flow Details
Flow Name: Payment_Meals_Update_Ver_3
Type: Workflow
Version: 1
Status: Active
Flow Interview Details
Interview Label: Payment_Meals_Update_Ver_3-1_InterviewLabel
Current User: Scott Walker (00XX000000#XXXXXXX)
Start time: 4/3/2017 4:46 PM
Duration: 0 seconds
How the Interview Started
Scott Walker (00X0000000000) started the flow interview.
Some of this flow's variables were set when the interview started.
myVariable_old = null
myVariable_current = a00000000aa0000008
ASSIGNMENT: myVariable_waitStartTimeAssignment
{!myVariable_waitStartTimeVariable} Equals {!Flow.CurrentDateTime}
Result
{!myVariable_waitStartTimeVariable} = "4/3/2017 4:46 PM"
DECISION: myDecision
Executed this outcome: myRule_1
Outcome conditions: and
1. {!myVariable_current.Payment_for__c} (Lunch Billing) Equals Lunch Billing
Logic: All conditions must be true (AND)
RECORD CREATE: myRule_1_A1
Create one Meal_Transaction__c record where:
Student__c = {!myVariable_current.Student__c} (null)
Transaction_Amount__c = {!myVariable_current.Amount_Paid__c} (1)
Transaction_Date__c = {!myVariable_current.CreatedDate} (4/3/2017 4:46 PM)
Transaction_Type__c = Credit
Result
Failed to create record.

Error Occurred: This error occurred when the flow tried to create records: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY: Meal_Transaction_AIAIAD: execution of BeforeInsert caused by: System.ListException: List index out of bounds: 0 Trigger.Meal_Transaction_AIAIAD: line 24, column 1. For details, see API Exceptions.

I have mapped the fields and I believe they are correct, as follows:

User-added image

the fields on the right are:

Student__c
Amount_Paid__c
CreatedDate


Any help really appreciated I really need to get this to work
 
We have users in both Classic and Lightning using the standard "New" button on leads.  I need to override the standard "New" button and redirect the user to a lightning app.  I created a VF page action that will redirect the user to the lightning app.  Everything works great however for lightning users, the redirect opens a new tab in the browser.  How do I keep the redirect on the same browser window in lightning?  Do I need to create a VF page pulling in a lightning component?
My salesforce for outlook account was automatically logged out but when I click to log back in and enter my credentials I get this message: 
User-added image
 
//BlockContentLinkTrigger
trigger BlockContentLinkTrigger on ContentDocumentLink (before insert) {  
    for(ContentDocumentLink  contDocL : Trigger.new) {
      if (CDLHelper.isSharingAllowed(contDocL)) {  
          contDocL.addError('Pièce joint bloquée depuis objet ContentDocumentLink');
     } 
   }  
}

//CDLHelper
public class CDLHelper {
    public static boolean isSharingAllowed(ContentDocumentLink cdl) {
        //String docId = cdl.ContentDocumentId;        
        ContentVersion version = [select PublishStatus, FileExtension from ContentVersion
                                  where ContentDocumentId =: cdl.ContentDocumentId limit 5];              
        if (version.PublishStatus.equals('P') && (version.FileExtension != 'null')) {
            return false;
        }
        return true;
    }
}

 
Hi,
I need update the fields when I create a new register and when I update the same.
I created a trigger that execute a method that make this update.

When I create a new register This method works, and when I try update occurs a error.

Can you evaluate my code and see if I did the right way, and what is wrong?

Trigger code:
Trigger INSERT
trigger CalcularTudoTrigger on Item_de_oportunidade__c (after insert) {
    
    Item_de_oportunidade__c item = new Item_de_oportunidade__c();
    item = [SELECT Id, Name, Margin__c, Sales_Type__c, nome_oportunidade__c, Category__c, Extra_Expenses__c
            FROM Item_de_oportunidade__c
               WHERE Id IN : Trigger.newMap.keyset() limit 1];
    
    Opportunity op = new Opportunity();
    op = [SELECT Id FROM Opportunity WHERE Id = : item.nome_oportunidade__c];

    if(trigger.isAfter){
         if(trigger.isInsert){
            AutomatizaCalculos.inserirCalculoMVS(item.Id, op.Id, item.Sales_Type__c, item.Category__c, item.Margin__c, item.Extra_Expenses__c);
         }
    }
}

Trigger UPDATE
trigger CalcularAtualizacao on Item_de_oportunidade__c (before update) {
    
    Item_de_oportunidade__c item = new Item_de_oportunidade__c();
    item = [SELECT Id, Name, Margin__c, Sales_Type__c, nome_oportunidade__c, Category__c, Extra_Expenses__c
            FROM Item_de_oportunidade__c
               WHERE Id IN : Trigger.newMap.keyset() limit 1];
    
    Opportunity op = new Opportunity();
    op = [SELECT Id FROM Opportunity WHERE Id = : item.nome_oportunidade__c];

    if(trigger.isBefore){
         if(trigger.isUpdate){
            AutomatizaCalculos.inserirCalculoMVS(item.Id, op.Id, item.Sales_Type__c, item.Category__c, item.Margin__c, item.Extra_Expenses__c);
         }
    }

}

APEX CODE:

global class AutomatizaCalculos {
    
    public static void inserirCalculoMVS(String id_item, String regional, String tipoVenda, String categoria, Decimal margem, Decimal gastos){
        Item_de_oportunidade__c item = new Item_de_oportunidade__c();
        item = [SELECT Id, Name, Sales_Type__c, Category__c, Margin__c, Extra_Expenses__c FROM Item_de_oportunidade__c WHERE Id = : id_item];
        
        if(regional == 'AR'){
            if(tipoVenda == 'FEE'){
                item.MVS__c = (margem * 0.956) - gastos;
                inserirCalculoComissao(item.MVS__c, item.Id, categoria);
            }else{
                item.MVS__c = margem - gastos;
                inserirCalculoComissao(item.MVS__c, item.Id, categoria);
            }
            
        }else if(regional == 'CL' || regional == 'US'){
                item.MVS__c = margem - gastos;
            inserirCalculoComissao(item.MVS__c, item.Id, categoria);
        }else{
            if(tipoVenda == 'FEE'){
                item.MVS__c = (margem * 0.8725)-gastos;
                inserirCalculoComissao(item.MVS__c, item.Id, categoria);
            }else{
                item.MVS__c = margem - gastos;
                inserirCalculoComissao(item.MVS__c, item.Id, categoria);
            }  
        }
    update item;
    }
    public static void inserirCalculoComissao(Decimal mvs, String item_id, String categoria){
        Item_de_oportunidade__c item = new Item_de_oportunidade__c();
        item = [SELECT Id, Name, Margin__c, MVS__c, MS_Customer__c, Category__c FROM Item_de_oportunidade__c WHERE Id = : item_id];
        if(categoria == 'IT SERVICES' || categoria == 'MANAGED SERVICES'){
            if(item.MS_Customer__c == true){
                item.Fee_Pre_Sales__c = mvs *0.015;
                item.Fee_Pre_Manager__c = mvs * 0.075;
                item.Fee_Pre_Rep__c = mvs * 0.03;
            }else{
                item.Fee_Pre_Sales__c = mvs *0.03;
                item.Fee_Pre_Manager__c = mvs * 0.015;
                item.Fee_Pre_Rep__c = mvs * 0.06;
            }
            
        }else{
            if(item.MS_Customer__c == true){
                item.Fee_Pre_Sales__c = mvs *0.015;
                item.Fee_Pre_Manager__c = mvs * 0.075;
                item.Fee_Pre_Rep__c = mvs * 0.03;
            }else{
                item.Fee_Pre_Sales__c = mvs *0.02;
                item.Fee_Pre_Manager__c = mvs * 0.01;
                item.Fee_Pre_Rep__c = mvs * 0.04;
            } 
        }
        
        update item;
    }
}

Thanks
Rafael
I have a custom object called Service Contract. The object contains the following fields Effective Date (date) and Calls Per Year (number) End Contract (checkbox). 

When a user sets up the service contract for a customers machine the customer will decide how many times per year they want the machine serviced.

For example: Starting April 1,2017 I want my machine serviced 2 times per year.
I need the event/reminder to tell the user on October 1 and April 1 to create a work order untill End Contract is checked. 
I have no idea how to work this out. My expirence with Apex is null, I do have other programing expirience and want to learn how to do this just really need some help. 

I had been advised previously to create a custom setting which I have but do not know how to proceed. 
I created a custom object and a Submit for Approval button appeared on it that I can't remove from the page layout.  I have no approval processes linked to it, no approval history, no Visualforce.  It's tangentially linked to Contracts, but I have three layers of custom master-detail objects linked to Contracts where the Submit button is not present.  The lowest level object in that hierarchy has a lookup to the object in question, but there are no lookups or master-detail fields on the object with the button.  Frustratingly, all users see the button, even the ones who only have read access to the records.

What on earth did I do to make this button appear and how do I get rid of it? 
Hello,

I have a custom sObject called AccountDetail that is the child in a lookup relationship with Account. It is also the parent in a lookup relationship with Opportunity. In my situation, I have Master Accounts that have AccountDetail objects, and I have Child Accounts that have Opportunity objects. Here's a diagram to help you visualize these relationships:

Diagram describing relationship between the relevant sObjects
I need to find all the Child Accounts related to each Master Account based on the relationships between their Opportunity and AccountDetail objects (I understand that organizing the data this way does not seem to make sense, but because of reasons outside of my control, this is how I have to do it). 

The query I am trying to use looks like this:
List<Account> accounts = 
   [SELECT Account.Id, Account.Name FROM Opportunity
    WHERE AccountDetail__c IN 
    (SELECT Id FROM AccountDetail__c
    WHERE Account__r.Id= :masterAccountId)].Account;
but this results in an Illegal assignment from Account to List<Account> error.

How do I make this query work to select all the Child Accounts instead of just one? Is there a better way to query the Child Accounts?
I have a custom button that SELECTS a Product for the Opportunity Lines.   This works great

Addition that is needed:
When the product is SELECTED and the Number of Years = 1 or greater  ---  I need it to populate a value  that is on the Opportunity Line Number that equals the number of years.  I am not sure the best way to get this to work.  If the Number of Years = 0 I do not want to change the dollar value for them.  


Do I need to use a Flow or Process builder?
 
Muddling my way through my first visual force page; not a developer by trade.  I've created a visual force button that will output the content of a related list to my opportunities (Visit Report) to a PDF file so that people can easily scroll through all VR's associated with an Opportunity & share with non-SF users.  My code is listed below.  

I have everything working as I like except the following 2 elements which I'm not sure how to handle (hoping for some help):

1) I want to sort the output Descending by the report date field
2) I want to make the headers of the table appear at the top of each page (repeating headers)

Can anybody help with this?  It seems simple but I'm getting lost in the details.
 
<apex:page standardController="Opportunity" renderAs="PDF">
<head>
<style>
@page { size:landscape;}
.headerRow .TableTitle {
            background-color: #139cd8 !important;
            cellPadding="5";}
            body {font-family: 'Arial Unicode MS'; font-size:12px}


 </style></head>
 <apex:image id="logo1" url="/servlet/servlet.ImageServer?id=015i0000002XNDw&oid=00D630000009OtH&lastMod=1394633629000" width="25%" height="25%"/>
 <br/>
 <apex:pageBlock >

        <apex:pageBlockTable value="{!Opportunity.Visit_reports__r}" var="item" cellpadding="5" columnsWidth="5%,5%,5%,10%,65%" border="1">
            <apex:column style="vertical-align:top; text-align:center" headerValue="Name" headerClass="TableTitle" value="{!item.Name}"/>
            <apex:column style="vertical-align:top; text-align:center" headerValue="Account" headerClass="TableTitle" value="{!item.Account__c}"/>
            <apex:column style="vertical-align:top; text-align:center" headerValue="Report Date" headerClass="TableTitle" value="{!item.Report_Date__c}"/>
            <apex:column style="vertical-align:top; text-align:left" headerValue="Purpose of Visit" headerClass="TableTitle" value="{!item.Purpose_of_Visit__c}"/>
            <apex:column style="vertical-align:top; text-align:left" headerValue="Visit Details" headerClass="TableTitle" value="{!item.Visit_Details__c}"/>
        </apex:pageBlockTable> 
        </apex:pageBlock>
</apex:page>

 
User-added image
User-added image

I Can not find any certificates that are expiring soon. What Should i do?
Processbuilder allows me to create nearly 17 Scheduled actions per Criteria, but would like to know if there is actually any limit or is it implied upon execution of the critiera... There is no direct answer in documentation...
Hello
Has anyone worked on soap api & rest api testing & java application testing?
what are the commonly used tools?
how to perform technical & function testing?
what the pros and cons involved?

Pls provide explanation.

Thanks
Pooja
Hi,
In the below, there are two pageblock, in first block is to display the list of Account and second block is to insert the account.And inserted account in second block should be dynamicaly displayed in 1st block. when I click on Save button it's showing the below error.
System.DmlException: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [Account Name]: [Account Name]
 
Please can anyone help me to solve this error.

<apex:page controller="multiAccountInsert">
    <apex:form >
        <apex:pageBlock >
         
            <apex:pageBlockTable value="{!accts}" var="a" reRender="display" >
                  <apex:column value="{!a.Name}"/>  
                  <apex:column value="{!a.Industry}"/>
                  <apex:column value="{!a.phone}"/>             
            </apex:pageBlockTable>
     </apex:pageBlock>
         <apex:pageBlock >
              <apex:pageBlockButtons location="top" >
                <apex:commandButton value="Save" action="{!Save}" id="display"/>
            </apex:pageBlockButtons>
                <apex:pageblocksection >
                    Enter Name: <apex:inputText value="{!at.Name}"/>
                </apex:pageblocksection>
         </apex:pageBlock>
    </apex:form>
</apex:page>
------------------------------------------
public class multiAccountInsert{

    public Account at { get; set; }

    public PageReference Save() {
    at = new Account();
    insert at;
        return null;
    }


    public List<Account> accts {get; set;}
        
        public multiAccountInsert(){
        accts = new List<Account>();
        accts = [Select id, Name, Industry, Phone from Account];
       }
}
Hi,

First bear with me, I'm an admin learning Apex.

I created a trigger that creates an Opportunity once an Account is created, it's working great but im struggling with the test class.

User-added image

I realize I have an issues with line 5, but im unsure how to insert the date fields into the test account that will then pull through to the new test opportunity (I tried to remove them and got an error that Variable did not exist).  
User-added image

Thoughts?  Help? 

 
Hi All,
I have written batch apex to insert data in Task from two objects.
I am able to get data from Obj1__c. I am not able to get from Obj2__c
Here is my code.
 
global class batchTwo Implements Schedulable, Database.Batchable<sObject>{
global void execute(SchedulableContext sc) {
    Database.executeBatch(this);
}

global database.queryLocator start(Database.BatchableContext BC) {
    
    
        return database.getQueryLocator([SELECT Id,AccountId__c,F1__c,F2__c FROM Obj1__c]);
    
} 

global void execute(Database.BatchableContext BC, list <obj1__c> scope) {

    List <Task> taskList = new List<Task>();

   Map<Id, Obj2__c> mapObj2=new Map<Id, Obj2__c>([SELECT Account_Name__r.Id,Obj2_F2__c FROM Obj2__c]);
    
    for(Obj1__c c : scope) {
            Task tsk             = new Task();
            if(mapObj2.containsKey(c.AccountId__c)) {
             Obj2__c tmpSales = mapObj2.get(c.AccountId__c);
            
             tsk.F1__c=tmpSales.Obj2_F2__c;
             
            }
            
            tsk.WhatId           = c.AccountId__c;
            tsk.ActivityDate     = System.today();
            tsk.Status           = 'Open';
            tsk.Priority         = 'Normal';
            tsk.Subject          = 'call';
            tsk.P1__c=c.F1__c;
            tsk.P2__c=c.F2__c;
            
           taskList.add(tsk);
    } //close for-loop

   
        insert taskList;
    
       
    
} 

global void finish(Database.BatchableContext BC) {


} 
}

I am getting problem in Line no. 21 to 24.
Please suggest me what changes need to be done.
Please help me.
Thanks in Advance
I have an interesting trigger on Campaign Member that needs to check a value on the associated Lead and associated Campaign and if both are TRUE, it should fire and update a few fields.  The challenge I'm having is that I can't figure out how to get both the Campaign and Lead variables inside of one for loop, without creating a loop inside of a loop, which will inevitably give me a DML insert error.  I create two Sets to get the IDs of the respective Leads and Campaigns, however, when I try to add the Campaign inside of my for loop I'm receiving a "variable doesn't exist" error.  I understand why...it's because I'm creating a "for"' on cml and not cmc (see below).  

I've commented out the code that is giving me issues.  How do I loop through two different objects that are related by a m2m (Campaign Member), relate them to each other, check for values in both Lead and Campaign, then update my Lead?  Any suggestions?
 
trigger deactivateCampaignSetToResting on CampaignMember (before Update) {
if(Trigger.IsBefore){
    if(Trigger.IsUpdate){
        Set<Id> leadIds = new Set<Id>();
        for (CampaignMember cml: Trigger.new){
            leadIds.add(cml.LeadId);
        }
        Set<Id> campaignIds = new Set<Id>();
        for (CampaignMember cmc: Trigger.New){
            campaignIds.add(cmc.CampaignId);
        }
        Map<Id, Lead> LeadMap2 = 
            new Map<Id, Lead>([SELECT Id, Current_Campaign__c, Status 
                              FROM Lead 
                              WHERE Id IN :LeadIDs]);
        List<Lead> leadToUpdate2 = new List<Lead>();
        Lead associatedLead2;
        
        Map<Id, Campaign> CampaignMap = 
            new Map<Id, Campaign>([SELECT Id, IsActive
                                    FROM Campaign
                                    WHERE Id IN :CampaignIds]);
        
        for (CampaignMember cml: Trigger.new){
            if(LeadMap2.containsKey(cml.LeadId)){
                associatedLead2 = LeadMap2.get(cml.LeadId);
                //if(CampaignMap.containsKey(cmc.LeadId)){
                //associatedCampaign = CampaignMap.get(cmc.CampaignId);    
                //    if( Trigger.oldMap.get(cmc.Id).IsActive != Trigger.newMap.get(cmc.Id).IsActive ){
                        if(associatedLead2.Current_Campaign__c!=NULL){
                            if(cml.Campaign_Lead_Status__c !='Pre-Contracting'){
                                if(cml.Campaign_Lead_Status__c !='Contracting'){
                                    if(cml.Campaign_Lead_Status__c !='Disqualified'){
                                        
                                        cml.Campaign_Lead_Status__c = 'Resting';
                                        associatedLead2.Status = 'Resting';
                                        associatedLead2.Current_Campaign__c = '';
                                        leadToUpdate2.add(associatedLead2);
                                    }
                                }
                            }
                            
                        } 
                        
                    //}
                    
                //}
                
            }
            
        }
        update leadToUpdate2;
    }
}
}

 
I am facing CPU time limit exceed error when code runs in the production, but the same code work perfectly in Full copy sandbox, which is having exact replica of the production.
Also error come only once in the production, when I first time run the VF page and after reloading the page, it works perfectly.

Although I know error is something, which I need to optimize code. But I just want to understand that why I am seeing such a strange behaviou? 
Thanks.
I have a method in Lightning server controller. This method will call an external API. And before calling out, it would check the token. if it's expiring soon, e.g. 1 day, the method will call a method to refresh token. 
The @future method should be very perfect for refreshing token. otherwise it would have a calloutexception error.

But now the problem is even I do nothing ('comment all the code') in the future method, it throws calloutexception error 'You have uncommitted work pending. Please commit or rollback before calling out'. if I remove @future annotation, it would be fine.

So strange!
Hello!  I hope I am conveying this correctly, please feel free to ask me if the below is confusing!

We use ServiceMax in our org to manage cases/etc.  SM comes with it's own suite of buttons that the techs are supposed to use to change the status on their cases.  However, since the inline editting for the 'Status' feild on cases cannot be easily turned off, they were just using the inline edit instead of the SFM buttons from SM to change the status.  

I can't have them doing this however as their are triggers which activate off of the buttons, that don't activate when using inline editting.  I wrote a validation rule to stop them and display a friendly reminder to use the SFM buttons, however I need a way to make an exception to the rule when they use the SFM buttons.  Right now this is my rule:
 
AND($Profile.Name = 'SVMX-BR-Service User', ISCHANGED(Status))

I need to add some sort of exception so that it does let the users modify the value of the status feild if they are doing through the SFM buttons...any ideas?  Is there a way to clarify that only inline editting should be locked down?

User-added image

Thanks in advance!
Hello - 

We are using a tool called Ninja Form and are having trouble connecting the web to lead form. My developer just gave me this message:

On the website plugin settings page there is a line that reads “Status: Salesforce has not enabled communication for your account. Please check with your Salesforce representative.”, which makes me think that we need to contact a Salesforce rep and ask him to manually activate or install the App I created. Could you help with that?

Can you please help us understand how to complete?

Thanks!!
We are looking for a fresh, eager, and passionate Salesforce developer who will work in a team to develop and support Salesforce.com platform for our growing family in Bulgaria. We are flexible when it comes to your location but we prefer to hire Bulgarian developer. This is a project based job, and we are looking for someone with the following skills:
 
  • 3+ years of professional experience in IT
  • Experience as a consultant is also preferred
  • Experience developing and delivering solutions to real customer problems,
  • 1+ year Force.com development experience
  • Salesforce Developer Certification would be advantageous
  • Design, develop, test our new system based on Salesforce.com
  • Project exposure including configuration, integration, implementation and customization
  • General problem-solving skills in Salesforce.com
  • Train other development resources on Salesforce development practices, as needed
  • An understanding of all major functional areas of Salesforce.com
  • Command on all the advaned developer concepts. 
  • Maintain alignment with Salesforce development best practices
  • Open to feedback. 
  • Willing to learn new things, technologies with respective to Salesforce.com platform
  • Willing to work in a team
I want to transfer complete data from one org to other org using eclipse IDE, can any one tell me full procedure to transfer because there are so many errors showing.

I downloaded one org's data by in eclipse as a project, and then i want to deploy to server(it means other org).. but it is showing so many errors.



How should i achieve this!! 
Hi All,

Can anyone help me i am getting below error in the visualforce page, i am displaying 12 dependent picklist in the pageblock section.

Visualforce pages may not display more than 10 dependent picklists together with their controlling fields

Thanks,
Anil Kumar 
Hi Folks,
can any one send  display error messages using java script ?
I am attempting to create a simple register "app" for a small sports charity.

Key Objects 
1Contact
2Participation_Events__c
3Participation_Data__c (junction between 1 and 2)

However, I would like to use another Junction (Participant_Group for example), so users can create groups and add multiple contacts to one event at a time - plus store that data in the pre mentioned junction  (3Participation_Data__c)

Additional Objects
4)Group_at_Session__c (lookup between 2 and 6)
5)Participant_Group_Member__c (junction between 1 and 6)
6)Participant_Group__c (information about the group)

Process
Create Contacts
Create Groups
Create Event, add group via lookup
system
- take lookup group and add group to the group_at_session junction (working fine)
- find contact ids in group (seems to be working)
- create new junction records with loop (not working)
- remove lookup value from the new Event record (not working)

There is a bunch of logic on the Participation_Events__c object, it may not make complete sense to do it this way, but the event seems to be the main focal point for the org. 

Here is the code, please take a look. 
 
trigger AddGroupToSession on Participation_Events__c (after insert, after update) {
    for(Participation_Events__c session : Trigger.new) {
        //if(trigger == before update)    
        //  session.Participant_Group__c = null;
        
        if (session.Participant_Group__c != null)
        {
            
            Group_at_Session__c sgroup = new Group_at_Session__c();
            
            sgroup.Sessions__c= session.id;
            sgroup.Participant_Group__c= session.Participant_Group__c;
            
            insert sgroup;
            
            ID groupId = session.Participant_Group__c; 
            
            system.debug('groupId - '+groupId);  
            
            
            list<Participant_Group_Member__c> contactIds = 
                [SELECT Contact__c
                 FROM Participant_Group_Member__c 
                 WHERE Crew_Name__c = :groupId 
                 //Limit 1
                ];            
            
            system.debug('contactIds 1st - '+contactIds.get(0));
            system.debug('contactIds last - '+contactIds[contactIds.size()-1]);
            system.debug('contactIds count - '+contactIds.size());                
            
            if(session.Register_Group__c == true){   
                for(integer i = 0; i < contactIds.size(); i++)  {
                    
                    Participation_Data__c obj = new Participation_Data__c(); 
                    
                    obj.Event__c = session.Id; 
                    obj.Participant_Registered__c= contactIds.get(i);
                    obj.Registered__c=TRUE;
                    
                    insert obj;
                    system.debug('Register = True - '+obj); 
                }
            }
            else{                
                for(integer i = 0; i < contactIds.size(); i++)  {
                    
                    Participation_Data__c obj = new Participation_Data__c(); 
                    
                    obj.Event__c = session.Id; 
                    obj.Participant_Registered__c= contactIds[i];
                    obj.Registered__c=FALSE;
                    
                    insert obj;
                    system.debug('Register = False - '+obj); 
                }
            }   
        }
    }
}



I keep getting the same error; I was hoping someone could help. Error message: "Illegal assignment from Participant_Group_Member__c to Id", which occurs on lines (38,51). However, the system.debug shows that the correct Contact Ids are being pulled by the SOQL query, so I am a bit confused. This is my first attempt at coding, so please explain where I've gone wrong.

Thank you in advance!


 
Hi,

I am getting "Failed to process API response" on the browser console immidiately after page refresh. No Open CTI function were used. I only added
https://<my instance>.my.salesforce.com/support/api/40.0/interaction.js to the html code.
It was working fine two months ago. Any ideas?

Thank you
 
I've got my flow launching and  cpatuing most info.  And it is ready to create a related record but heres where i'm spinng my wheels.

I'm grabbing the Oppty ID from the link attached to the button.  Flow starts, my screen entries are fine but the next step fails as there is a required field is missing.

My opportunity has a related record - RecordA
I'm trying to create another related record (RecordB) that is related to the Opportunity and the RecordA.
The required field error is coming from missing RecordA name that needs to populate the new RecordB being created by the flow.

I've tried creating a formula pulling the RecordA name off the Opportunity  as part of "create New RecordB" but can't seem to get that to work.   Any thoughs what I'm missing?  Thanks in advance!
 
!! Job Location: Riga, Latvia !!
Ekleft is an international company, which provides services in IT outsourcing/outstaffing, recruitment and DDC. The company was founded in 2008. We provide our customers with highly qualified IT resources and service all over the globe. Ekleft specializes in the establishment of DDC from the scratch in the EU, CIS and Latin America. IT has successfully completed complex projects related to outsourcing activities and DDCs with the ambition to fulfill tasks of any complexity to support our Clients in holding their leading market position. Our customers are large multinational companies investing in IT development and executing complex IT projects. Therefore, we are always on the hunt for result-driven and customer-oriented people to join our growing team with the opportunity to work in an international environment and explore one of the fastest emerging and most complex markets.
This opportunity gives you a chance not only to work in a great team of talented professionals who share their passion for technology and innovation, but also to challenge yourself by participating in interesting projects with a competitive salary rate!
Responsibilities:
  • Design, develop, test, document, and deploy high quality business solutions on the Force.com platform in Salesforce
  • Develop on-target Salesforce solutions, leveraging Force.com APEX Class, Triggers, Visual Force Pages, Components, and Validation Rules
  • Play a technical role in evaluating new CRM technologies/add-ons and develop plans for their implementation into Salesforce org.
  • Provide on-going technical support for existing custom APEX code being used on the Force.com platform
  • Train other development resources on Salesforce development practices, as needed. Maintain alignment with Salesforce development best practices
  • Leverage any past experience with .NET development, JAVA, web services, and/or SQL Server development to build or maintain existing non-Salesforce Custom Applications, or build future integration points between Salesforce and Custom Applications
  • Project duration: 12 month
 
Required skills and experience:
  • 3+ years of professional experience in IT
  • Experience as a consultant is also preferred
  • Experience developing and delivering solutions to real customer problems, preferably with an emphasis on Sales, - CustomerService, and/or Marketing issues
  • 1+ year Force.com development experience, with a strong focus on Apex and Visualforce development
  • 2+ years Java or C# development experience, and 3+ years web application development experience, including solid experience with Java or C#, as well as HTML, JavaScript, and CSS
  • Solid knowledge of SOQL
  • Good oral and written communication skills in English
  • Ability to work independently and as part of a team
 
What you can expect from us:
  • Work in large-scale Nordic projects
  • Solid benefits package – sports, medical care, etc.
  • Friendly and positive work environment

Who we are

Decoded Solutions are a software development studio based in Bournemouth. Our goal is to create and commercialise market leading software that allows brands to better understand the consumer electronics market.
Awarded with the Investors in People Silver award, we recognise that it is people who make our business and aim to provide our employees with an exceptional employment experience through engagement, personal development & our office environment.
We pride ourselves on thinking big and working as a team to achieve our goals, and we like to do it all with a smile on our face. This is a great opportunity to join a business that’s going places and has big ambitions for the future.
 

What we are looking for

We are looking to recruit a forward-thinking Lead Developer to head up one of our in-house product development teams.
In the role of a Lead Developer you will be expected to find a balance between excellent technical knowledge, strong commercial awareness and great management skills – supporting and developing your team to achieve the best results.
As the leader of a development team you will be take responsibility for managing the output of your team in line with the agreed plan and our ways of working.

 

Skills and Experience needed

  • Experience working in and ideally leading a small development team
  • Strong motivational and communication skills that enable you to lead a team of technical specialists
  • Able to solve complex technical problems with practical and commercial solutions
  • An understanding of different development processes and frameworks (in particular Scrum) would be very advantageous
  • A strong proficiency with MySQL, C# (ASP.NET, MVC framework) and Java would be expected and ideally you would have experience with JavaScript, HTML, CSS, Angular JS, ReactJS and Docker
  • A strong understanding of both Windows and Linux server environments
  • Experience using and managing source controls, ideally GIT
  • Experience with web services, continuous integration, unit testing & mocking frameworks
  • Knowledge of Objective C/Swift and Android development would also be an advantage but not a necessity, as would experience of mobile and cloud platform technologies and tools
Getting this error in the Analytics Module - Add Selectors That Allow Users to Filter the Dashboard Results

User-added image
Hello guys,
I've got some problem with my save method, nothing happen, even the System.debug is not launch on the Debug Log;
Thanks for your help
Here my VFP and Controller code : 
public with sharing class ManageFAST {

	public List<SelectOption> 							quarterList {get;set;}
	public List<SelectOption> 							fastType{get;set;}
	public Map<Id, FAST__c>								mapFast{get;set;}
	public FAST__c 										fast{get;set;}
	public List<FAST_OPP__c> 							fastOppList{get;set;}
	//public List<AggregateResult> 						fastOppListSum{get;set;}

	public String 										typeOfOpp{get;set;}
	public Decimal 										sumOfAmount{get;set;}

	//public List<FAST__c> 								fastList{get;set;}

	private List<ManageOpp>								manageOppList{get;set;}
	private manageUser 									oppUser;
	private ManageOpp 									oppOpp;
	public Date 										quarter{get;set;}
	public String 										selectedQuarter {get;set;}
	public Date 										selectedQuarterReturn{get;set;}
	public Date 										testdate{get;set;}



	public ManageFAST() {
		fast = new FAST__c();
		//fastList = new List<FAST__c>();
		fastOppList = new List<FAST_OPP__c>();
		oppUser = new ManageUser();
		oppOpp = new ManageOpp();

		oppUser.load(UserInfo.getUserId());
		quarter = Date.today();
		quarterList = loadQuarterList();
		loadFastType();
		loadFAST();
		loadFASTOPP();
		initFASTOppList();
	}


	public List<SelectOption> loadFastType(){
		fastType = new List<SelectOption>();
		fastType.add(new SelectOption('none', '-- Select Type --'));
		fastType.add(new SelectOption('Optimist', 'Optimist'));
		fastType.add(new SelectOption('Forecast Exit', 'Forecast Exit'));
		fastType.add(new SelectOption('Pessimist', 'Pessimist'));
		return fastType;
	}

	public List<SelectOption> loadQuarterList() {
		List<SelectOption> optionsquarter = new List<SelectOption>();
		List<Period> resultsquarter = [SELECT EndDate, FullyQualifiedLabel, StartDate, Type
		FROM Period 
		WHERE Type = 'Quarter' AND StartDate >= LAST_YEAR];
		for(Period rq : resultsquarter){
		optionsquarter.add(new SelectOption(String.valueOf(rq.get('StartDate')),String.valueOf(rq.get('FullyQualifiedLabel'))));
		
		}
		return optionsquarter;
	}


	public void loadFAST(){
		if(selectedQuarterReturn == null){
			selectedQuarterReturn = Date.today();
		} else {
			selectedQuarterReturn = Date.valueOf(selectedQuarter);
		}
		List<FAST__c> fastList = new List<FAST__c>();
		fastList = [SELECT Id, Sales_ID__c, Forecast_Manager_ID__c, Quarter_Date__c, Commit_Manager__c, Transactionnal_Amount_Forecast_Exit__c, 
					Transactionnal_Amount_Optimistic__c, Transactionnal_Amount_Pessimistic__c,Opp_Amount_Optimist__c,
					Opp_Amount_Forecast_Exit__c, Opp_Amount_Pessimist__c
					FROM FAST__c 
					WHERE Sales_ID__c =: oppUser.getId()
					//AND Quarter_Date__c >=:selectedQuarterReturn 
					//LIMIT 1
					];

		if(fastList.isEmpty()){
			fast = new FAST__c();
			fast.Sales_ID__c = oppUser.getId();
			fast.Forecast_Manager_ID__c = oppUser.getManagerId();
			fast.Transactionnal_Amount_Pessimistic__c = 0;
			fast.Transactionnal_Amount_Optimistic__c = 0;
			fast.Transactionnal_Amount_Forecast_Exit__c = 0;
			//fast.Quarter_Date__c =:selectedQuarterReturn
			fast.Opp_Amount_Pessimist__c = 0;
			fast.Opp_Amount_Optimist__c = 0;
			fast.Opp_Amount_Forecast_Exit__c = 0;
			fast.Commit_Manager__c = 0;
		} else {
			fast = fastList.get(0);
		}
	}


	public void loadFASTOPP(){

		Date selectedQuarterReturn = Date.valueOf(quarterList.get(0).getValue());
		Date selectedQuarterReturnNext = Date.valueOf(quarterList.get(1).getValue());
	
			if(selectedQuarter == null){
				selectedQuarterReturn = Date.today();
			} else {
				selectedQuarterReturn = Date.valueOf(quarterList.get(0).getValue());

			}
			//System.debug(selectedQuarterReturn);
			//System.debug(selectedQuarterReturnNext);
	
			fastOppList = [SELECT Id, Opp_ID__c, IsClosed__c, Type__c, Opp_Amount__c, FAST_ID__c
			FROM FAST_OPP__c 
			WHERE IsClosed__c != true
			AND Opp_ID__r.CloseDate >=: selectedQuarterReturn
			];		
	}

	public void initFASTOppList(){
		oppUser.loadOpportunityList(quarter);
		for(ManageOpp mo : oppUser.getOpportunityList())
		{

			Map<Id, FAST_OPP__c> testMap = new Map<Id, FAST_OPP__c>();
			for(FAST_OPP__c fo : fastOppList){
				testMap.put(fo.Opp_ID__c, fo);
				//System.debug('1er test MO' + fastOppList);
			}

			if(!testMap.containsKey(mo.getOppId())){
				FAST_OPP__c fastOpp = new FAST_OPP__c();
				fastOpp.Opp_ID__c = mo.getOppId();
				fastOpp.FAST_ID__c = fast.Id;
				fastOpp.IsClosed__c = mo.getIsClosed();
				fastOpp.Opp_ID__r = new Opportunity();
				fastOpp.Opp_ID__r.Amount = mo.getAmount();
				fastOpp.Type__c = 'none';
				fastOppList.add(fastOpp);
			}
		}
	}


	public FAST__c getFAST(){
		return this.fast;
	}
public PageReference goSave() {
		System.debug('fastOppList before for = ' + fastOppList);

		List<FAST_OPP__c> fastOppListToSave = new List<FAST_OPP__c>();
		
		for(FAST_OPP__c fol : fastOppList){
			System.debug('fastOppList a the begining of the for' + fastOppList);
			fol.Opp_ID__r = null;
			//if(fol.Type__c == null){
				//fol.Type__c = typetype;
				fol.Type__c = this.typeOfOpp;
			//}
			//fol.Type__c = typetype;
			System.debug('fastOppListToSave before the add' + fastOppListToSave);
			fastOppListToSave.add(fol);
			System.debug('fastOppListToSave during for' + fastOppListToSave);
			//if(fol.Type__c != 'none'){
			//	fastOppListToSave.add(fol);
			//	System.debug('fastOppListToSave during SAVE' + fastOppListToSave);
			//}
		}
			System.debug('fastOppListToSave after for' + fastOppListToSave);

		try {
			System.debug('fastOppListToSave during save' + fastOppListToSave);
			upsert fastOppListToSave;
		} catch (exception ex) {
			System.debug(ex);
		}
		return null;
	}
 
<apex:page showHeader="true" sidebar="true" controller="ManageFAST" >

<apex:includeScript value="{!URLFOR($Resource.jquery, '/jquery-ui-1.10.3.custom/js/jquery-1.9.1.js')}" />
<apex:includeScript value="{!URLFOR($Resource.jquery, '/jquery-ui-1.10.3.custom/js/jquery-ui-1.10.3.custom.min.js')}" />





<apex:form id="formId">
<script type="text/javascript">
			$j = jQuery.noConflict();

			$j(document).ready(function() {
					var total = 0;
					$j('.optimist').each(function(){
						var t = $j(this).parent().parent().find('.optimist').val();
						total += parseFloat(t); 
					});
					$j('.grandTotal').val(total);

					$j('.type_opp').change(function(){			
					var opp_amount = $j(this).parent().parent().find('.amount_to_copy').text();

						if($j(this).parent().parent().find('.type_opp').val() == 'Pessimist'){
							$j(this).parent().parent().find('.pessimist').val(opp_amount);
							$j(this).parent().parent().find('.forecast_exit').val(opp_amount);
							$j(this).parent().parent().find('.optimist').val(opp_amount);

						} else if ($j(this).parent().parent().find('.type_opp').val() == 'Forecast Exit'){
							$j(this).parent().parent().find('.pessimist').val('');
							$j(this).parent().parent().find('.forecast_exit').val(opp_amount);
							$j(this).parent().parent().find('.optimist').val(opp_amount);

						} else if ($j(this).parent().parent().find('.type_opp').val() == 'Optimist'){
							$j(this).parent().parent().find('.pessimist').val('');
							$j(this).parent().parent().find('.forecast_exit').val('');
							$j(this).parent().parent().find('.optimist').val(opp_amount);
						}
				});
			});
		</script>


<br/><br/>
<apex:selectList value="{!selectedQuarter}"  size="1">
	<apex:selectOptions value="{!QuarterList}" />
	<apex:actionSupport event="onchange" action="{!loadFASTOPP}" reRender="formId"/>
</apex:selectList>
<br/><br/>
<apex:outputText value="{!selectedQuarterReturn}"></apex:outputText>

<apex:pageBlock>
	<apex:pageBlockTable value="{!fastOppList}" id="table" var="f" >
				<apex:column headerValue="Opportunity Name" value="{!f.Opp_ID__c}"/>
				<!-- <apex:column headerValue="Opportunity Account" value="{!f.Opp_ID__r.Account.Name}"/> -->
				<apex:column headerValue="Amount" styleClass="amount_to_copy" value="{!f.Opp_Amount__c}"/>
				<apex:column headerValue="Type">
					<apex:selectList styleClass="type_opp" value="{!typeOfOpp}"  size="1">
						<apex:selectOptions value="{!fastType}" />
					</apex:selectList>
				</apex:column>

				<apex:column headerValue="TYpe" value="{!f.Type__c}">
				</apex:column>

				<apex:column headerValue="Total Pessimistic">
				<apex:inputText styleClass="pessimist" value="{!f.Opp_Amount__c}"/>
				</apex:column>

				<apex:column headerValue="Total Forecast Exit">
				<apex:inputText styleClass="forecast_exit" value="{!f.Opp_Amount__c}"/>
				</apex:column>

				<apex:column headerValue="Total Optimistic">
				<apex:inputText styleClass="optimist" value="{!f.Opp_Amount__c}"/>
				</apex:column>
				<apex:column headerValue="Is closed ?">
				<apex:outputText value="{!f.IsClosed__c}"/>
				</apex:column>
	</apex:pageBlockTable>
</apex:pageBlock>
	
<apex:pageBlock>
		<apex:outputText>Commit Manager </apex:outputText>
		<apex:inputText value="{!sumOfAmount}" styleClass="grandTotal"/>
</apex:pageBlock>

<apex:commandButton value="Save Value" action="{!saveValue}"/>
<apex:commandButton value="SaveMoi" action="{!saveMoi}"/>
<apex:commandButton value="GoSave" action="{!goSave}"/>
<apex:commandButton value="TEST" action="{!testTest}"/>

<br/>

</apex:form>



</apex:page>

Thanks
Hi All,

I have array of string : one,two,three,four,"five1,five2", six ,seven,"eight1,eight2","nine",,eleven

I need output as :
one
two
three
four
five1,five2
six
seven
eight1,eight2
nine

eleven

Thanks in advance
 I want to show my all Opportunity in the account reated list with following condition with it -
  1. Stage Name should be Closed won and Close Date in future .
  2. List shows the Opportunity Name, Closed Date , Stage Name and Amount.
 
 Thaks in aadvance.
Unable to login  @ Dev Org. dectivate a flow assicated with login flow for system admin. unable to login  thrown error message while login " no active flow"
Hi,
I am new in salesforce. I have question about relationships. Is it possible to generate dynamically a generic link between objects? My scenario is to have a custom object with fields like object_id,object_name, field_id, field_name. I would like to build  links between my custom object and other objects.