• Ashwani
  • SMARTIE
  • 1331 Points
  • Member since 2013
  • Salesforce Consultant/Developer/Contributor


  • Chatter
    Feed
  • 32
    Best Answers
  • 0
    Likes Received
  • 7
    Likes Given
  • 3
    Questions
  • 379
    Replies
Global class BatchFirst1 implements database.batchable<sObject>{
    global database.querylocator start(database.batchablecontext BC){
       String acct = 'select id, name from account limit 10';
        return database.getQuerylocator(acct);
}
    global void execute(database.batchablecontext bc, list<account> acct){
    
        for(account acc : acct){
        
            acc.name= acc.name + 'checked';
        }
        update acct;
    }
     global void finish(Database.BatchableContext BC){
     Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
    
          mail.setToAddresses(new String[] {abcd@gmail.com});
       mail.setReplyTo('batch@acme.com');
       mail.setSenderDisplayName('Batch Processing');
        mail.setSubject('Batch Process Completed');
        mail.setPlainTextBody('Batch Process has completed');
 
        Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
}
      }
my intention is to send the email after completion of batch class finish method..
here i am getting error like   Error: Compile Error: unexpected token: '@' at line 16 column 58.
Please tell me the solution..
Thanks and regards,
Anji reddy.
Hi,

If I decalre a variable in the first part of my class outside any of the methods, it should be available within all of my methods yes?  But for some reason that's not working here, I don't understand what's wrong.  There must be somethign I'm missing

Thanks,
public class ContactReclassTest {
    
    String confirstName;
    String conlastName;
    List<Contact> conList = New List<Contact>();  // this should be seen by within all methods yes?
    
    ContactReclassTest() {
        conFirstName = 'Mathew';
        conlastName = 'Andresen';
        
    }
   
    
    public static void createContacts() {
        List<Contact> conList = New List<Contact>();  // If I don't put this in it says the variable doesn't exist
    for(Integer i = 0; i < 5; i++) {
        Contact con = new Contact(FirstName = 'Mathew', LastName = ('Andresen'+ i) );  //can't find the other strings I declared either
        conList.add(con);
    }
        insert(conList);
    
    }
}



 
I have a working trigger that updates a lookup field from a zipcode object when the zipcode name = the listing zip code on the lead.  However, I need to add an additional restriction, where the metro__c field on the lead = the metro__c field on the zip code table, and I'm not sure how to do this.  How would I add this restriction?

The working trigger is below:

trigger UpdateListingZip on Lead (before insert, before update) {
    Set<String> ListingZips = new Set<String>();

    for( Lead l : trigger.new ) {
        if( l.listing_zip_code__c != null && l.LAG_Offered__c!=TRUE && l.DTA_Lead__c !=TRUE) {
            ListingZips.add( l.listing_zip_code__c );
                        
 }
    }            

        // Now we have a set of unique zipcodes we want to verify, time to look them up.
    // I plan to build a map of the "match field" -> "full reference object"

    Map<String, zip_codes__c> MatchZips = new Map<String, zip_codes__c>();

    for(zip_codes__c obj : [SELECT  Id,
                                           zipcode__c
                                            FROM    Zip_Codes__c
                                            WHERE     zipcode__c IN :ListingZips] ) {MatchZips.put( obj.zipcode__c, obj );
    }
    // We have all the reference data we need, last loop on the each lead

    for( Lead l : trigger.new ) {

        if( l.listing_zip_code__c != null ) { // there IS a countrylist entry to deal with... so...

            if( MatchZips.containsKey(l.listing_zip_code__c) ) { l.Zip_Code_Lookup__c = MatchZips.get(l.listing_zip_check__c).ID; }}
}
}
Hi

I need a trigger on a chatter post, that once a chatter is posted on an account that a comment is inserted, mentioning the owner of this particular record.
I have in all honousty no idea where to start, any suggestions pls, as to code recipes etc? thx
<apex:page controller="storedata" showHeader="false">
<apex:form >
  <apex:pageBlock title="account details">
  <apex:pageBlockButtons >
   <apex:commandButton value="save" action="{!save}" status="acctid"/>
  
  </apex:pageBlockButtons>
   <apex:pageblockSection >
    <apex:inputField value="{!acc.name}"/>
    <apex:inputField value="{!acc.type}"/>
    <apex:inputField value="{!acc.phone}"/>
   </apex:pageblockSection>
   <apex:pageBlockSection >
    <apex:inputField value="{!acc.rating}"/>
   
   </apex:pageBlockSection>
  </apex:pageBlock>
</apex:form>
</apex:page>

public class storedata {

    public account getAccount() {
        return acc;
    }


    public account acc { get; set; }
   
     public storedata()
     {
      list<account> acc=[select id,name,type,phone,rating from account where id=:apexpages.currentpage().getparameters().get('id')];
      
        }

    public PageReference save() {
        update acc;
        return null;
       
}
}
When opening our production developer console, the menus at the top show empty drop down when clicked.  Some logs show at the bottom but nothing is useable.  One cannot open or edit any file or make queries. 

The browser console shows these errors:

(/_ui/common/apex/debug/ApexCSIPage) Uncaught TypeError: Cannot read property 'addCls' of null main.js:1764
Sfdc.provide.log main.js:1764
(anonymous function) main.js:1576
log main.js:1761
a.log main.js:1761
l main.js:1659
(anonymous function) main.js:1660


Uncaught TypeError: Cannot read property 'addCls' of null ext-all.js:18
Ext.define.addBodyCls ext-all.js:18
Ext.define.handleItemBorders ext-all.js:18
Ext.define.beginLayout ext-all.js:18
Ext.define.resetLayout ext-all.js:18
Ext.define.invalidate ext-all.js:18
Ext.define.invalidate ext-all.js:18
Ext.define.flushInvalidates ext-all.js:18
Ext.define.run ext-all.js:18
Ext.define.statics.flushLayouts ext-all.js:18
Ext.define.statics.updateLayout ext-all.js:18
Ext.define.updateLayout ext-all.js:18
Ext.define.doLayout ext-all.js:18
Ext.define.statics.open ApexIDEPanels_Ext4.js:178
n ApexIDEPanels_Ext4.js:116
(anonymous function) ApexIDEPanels_Ext4.js:118
SfdcDevConsole.ToolingAPI.query.continuation ApexIDEPanels_Ext4.js:118
Sfdc.isFunction.Sfdc.isFunction.b.success ApexIDECore.js:32
b
Hi folks.  So I'm trying to deploy my first app and having some errors.  Namely the lower four are bothering me.  The custom field 'Inquiry_Status__c' most truely does exist, as well as the 'X10_Piece_Unit_Cost__c' field as well.  But for some reason the deployment can't find them.  

Any advice appreciated, I'm looking into the top error, the ServQ__c error, that is another app and shouldn't even be appearing in this list.
 My woes
I've written the following in a test class attempting to achieve adequate code coverage by parsing XML nodes into various field values.  I want to reference the static resource XML file in test classes instead of entering the actual XML and assigning it to a XMLStr.  However, I am receiving the error stated above.
List<StaticResource> ifx;
		ifx = [Select Body from StaticResource where Name = '{Direct8_8_Decision}' LIMIT 1];
        string XMLStr = ifx.body.ToString();
        Dom.Document xmlDoc = new Dom.Document();
        xmlDoc.load(xmlStr);
        IFXLoadXML.IFXMain ifxObj = new IFXLoadXML.IFXMain(xmlDoc.getRootElement());
        System.assertNotEquals(null, xmlDoc);

What must be fixed in order for the Static Resource to be loaded into the test class, XML nodes evaluated etc.?
Hey,

Ive created a two-dimension array and initialized it like that:

        list<list<integer>> two_d_array = new list<list<integer>>();
        integer[] one_d_array = new list<integer>();
       
        for(integer i=0 ; i<d2_size ; i++){
            for(integer j=0 ; j<d1_size ; j++){
                one_d_array.add(0);
            }
            two_d_array.add(one_d_array);
        }
i wanna approach a direct cell like that:
   two_d_array[2][3] = 1289;
    or (do the same thing)
    two_d_array.get(2).set(3, 1289);

The problem is, by doing it it assign all column [3] as 1289.
The array will be like:
[0][3] = 1289
[1][3] = 1289
[2][3] = 1289
etc.

So how can i approach a direct cell. A specific one, not the all column.

Thx a lot!

Heres my Class

public with sharing class nCino_CustomerHealth{
    //Declare Public Variables
    List<Customer_Health__c> myCHList;
    public Set<String> cmSet {get; set;}
    public Set<String> amset {get; set;}
    public Set<String> seset {get; set;}
    
    public String CSMFilter {get;set;}
    public String SEFilter {get;set;}
    public String AMFilter {get;set;}
    
    public nCino_CustomerHealth() {
    
    
    cmSet = new Set<String>();
    for(Customer_Health__c chc : [SELECT Customer_Success_Manager__c FROM Customer_Health__c WHERE Customer_Success_Manager__c <> ' ']){
             cmSet.add(chc.Customer_Success_Manager__c);
            }
    amset = new Set<String>();
    for(Customer_Health__c cha : [SELECT Account_Manager__c FROM Customer_Health__c WHERE Account_Manager__c <> ' ']){
             amset.add(cha.Account_Manager__c);
            }

    seset = new Set<String>();
    for(Customer_Health__c chs : [SELECT Support_Engineer__c FROM Customer_Health__c WHERE Support_Engineer__c <> ' ']){
             seset.add(chs.Support_Engineer__c);
            }

        myCHList = [SELECT  Id, 
                        Name, 
                        Account__r.Name,
                        Account__c,
                        Master_Scorecard__c, 
                        Survey_Score__c, 
                        Data_Storage__c, File_Storage__c, 
                        Avg_Stage_Duration__c,
                        Days_to_Close1__c,
                        Days_to_close2__c,
                        Pass_Through_Rate2__c,
                        Pass_Through_Rate1__c,
                        Account__r.Handed_over_to_support__c
                FROM Customer_Health__c WHERE Account__r.Current_Customer__c='Yes'];
    }

    public List<SelectOption> getCSMItems() {
        List<SelectOption> csmoptions = new List<SelectOption>();
        csmoptions.add(new SelectOption('No Filter', 'Customer Success Manager'));
        csmoptions.add(new SelectOption(' ', 'No CSM'));
        for (String s : cmSet) {
           
            csmoptions.add(new SelectOption(s, s));
        }
        system.debug('***' + csmoptions);
        return csmoptions;
    }

    public List<SelectOption> getSEItems() {
        List<SelectOption> seoptions = new List<SelectOption>();
        seoptions.add(new SelectOption('No Filter', 'Support Engineer'));
        seoptions.add(new SelectOption(' ', 'No SE'));
        for (String a : seset) {
            seoptions.add(new SelectOption(a, a));
        }
        system.debug('***' + seoptions);
        return seoptions;
    }

    public List<SelectOption> getAMItems() {
        List<SelectOption> amoptions = new List<SelectOption>();
        amoptions.add(new SelectOption('No Filter', 'Account Manager'));
        for (String d : amset) {
            amoptions.add(new SelectOption(d, d));
        }
        system.debug('***' + amoptions);
        return amoptions;
    }
    
    public void RefreshTable() {
        system.debug('*** RefreshTable1');
        if(CSMFilter == 'No Filter' && SEFilter == 'No Filter' && AMFilter == 'No Filter') {
            myCHList = [SELECT  Id, 
                        Name, 
                        Account__r.Name,
                        Account__c,
                        Master_Scorecard__c, 
                        Survey_Score__c, 
                        Data_Storage__c, File_Storage__c, 
                        Avg_Stage_Duration__c,
                        Days_to_Close1__c,
                        Days_to_close2__c,
                        Pass_Through_Rate2__c,
                        Pass_Through_Rate1__c,
                        Account__r.Handed_over_to_support__c
                FROM Customer_Health__c WHERE Account__r.Current_Customer__c='Yes'];
            system.debug('*** All No Filter: ' + CSMFilter + ' | ' + SEFilter + ' | ' + AMFilter);

        } else if (CSMFilter != 'No Filter') {
            myCHList = [SELECT  Id, 
                        Name, 
                        Account__r.Name,
                        Account__c,
                        Master_Scorecard__c, 
                        Survey_Score__c, 
                        Data_Storage__c, File_Storage__c, 
                        Avg_Stage_Duration__c,
                        Days_to_Close1__c,
                        Days_to_close2__c,
                        Pass_Through_Rate2__c,
                        Pass_Through_Rate1__c,
                        Account__r.Handed_over_to_support__c
                FROM Customer_Health__c WHERE Account__r.Current_Customer__c='Yes' AND
                                            Customer_Success_Manager__c = :CSMFilter];
            system.debug('*** CSMFilter ' + CSMFilter);
        } else if (SEFilter != 'No Filter') {
            myCHList = [SELECT  Id, 
                        Name, 
                        Account__r.Name,
                        Account__c,
                        Master_Scorecard__c, 
                        Survey_Score__c, 
                        Data_Storage__c, File_Storage__c, 
                        Avg_Stage_Duration__c,
                        Days_to_Close1__c,
                        Days_to_close2__c,
                        Pass_Through_Rate2__c,
                        Pass_Through_Rate1__c,
                        Account__r.Handed_over_to_support__c
                FROM Customer_Health__c WHERE Account__r.Current_Customer__c='Yes' AND
                                            Support_Engineer__c = :SEFilter];
            system.debug('*** SEFilter ' + SEFilter);
        } else if (AMFilter != 'No Filter') {
            myCHList = [SELECT  Id, 
                        Name, 
                        Account__r.Name,
                        Account__c,
                        Master_Scorecard__c, 
                        Survey_Score__c, 
                        Data_Storage__c, File_Storage__c, 
                        Avg_Stage_Duration__c,
                        Days_to_Close1__c,
                        Days_to_close2__c,
                        Pass_Through_Rate2__c,
                        Pass_Through_Rate1__c,
                        Account__r.Handed_over_to_support__c
                FROM Customer_Health__c WHERE Account__r.Current_Customer__c='Yes' AND
                                              Account_Manager__c= :AMFilter];
            system.debug('*** AMFilter ' + AMFilter);
        }
    }
    
    public List<Customer_Health__c> getCHList(){
        return myCHList;
    }    
    
    public Decimal getNewRelease() {
        AggregateResult[] groupedResults = [SELECT COUNT(ID)totalSum FROM Customer_Health__c 
                                            WHERE Account__r.Handed_over_to_Support__c=True 
                                            AND (nCino_Version__c LIKE '%1.6%')];
        Decimal totalACV = (Decimal)groupedResults[0].get('totalSum');
        AggregateResult[] groupedResults2 = [SELECT COUNT(ID)totalAcc FROM Customer_Health__c 
                                                            WHERE Account__r.Handed_over_to_Support__c=True];
        Decimal totalNum = (Decimal)groupedResults2[0].get('totalAcc');
        return (totalACV/totalNum)*100;
    }
    
    public Decimal getAvgScore() {
        AggregateResult[] groupedResults = [SELECT SUM(Master_Scorecard__c)totalSum FROM Customer_Health__c 
                                            WHERE Account__r.Handed_over_to_Support__c=True];
        Decimal totalAmount = (Decimal)groupedResults[0].get('totalSum');
        AggregateResult[] groupedResults2 = [SELECT COUNT(ID)totalN FROM Customer_Health__c 
                                                            WHERE Account__r.Handed_over_to_Support__c=True];
        Decimal totalNum = (Decimal)groupedResults2[0].get('totalN');
        return (totalAmount/totalNum);
    }
    
    public Decimal getAvgSat() {
        AggregateResult[] groupedResults = [SELECT SUM(Survey_Score__c)totalSum FROM Customer_Health__c 
                                            WHERE Account__r.Handed_over_to_Support__c=True];
        Decimal totalAmount = (Decimal)groupedResults[0].get('totalSum');
        AggregateResult[] groupedResults2 = [SELECT COUNT(ID)totalN FROM Customer_Health__c 
                                                            WHERE Account__r.Handed_over_to_Support__c=True];
        Decimal totalNum = (Decimal)groupedResults2[0].get('totalN');
        return (totalAmount/totalNum);
    }

    public Decimal getInformatica() {
        AggregateResult[] groupedResults = [SELECT COUNT(Data_Integration__c)totalSum FROM Customer_Health__c 
                                            WHERE Account__r.Handed_over_to_Support__c=True AND Data_Integration__c='Informatica'];
        Decimal totalAmount = (Decimal)groupedResults[0].get('totalSum');
        return totalAmount;
    } 
    
    public Decimal getAvgPTR() {
        AggregateResult[] groupedResults = [SELECT SUM(Pass_Through_Rate2__c)totalSum FROM Customer_Health__c 
                                            WHERE Account__r.Handed_over_to_Support__c=True];
        Decimal totalAmount = (Decimal)groupedResults[0].get('totalSum');
        AggregateResult[] groupedResults2 = [SELECT COUNT(ID)totalN FROM Customer_Health__c 
                                                            WHERE Account__r.Handed_over_to_Support__c=True];
        Decimal totalNum = (Decimal)groupedResults2[0].get('totalN');
        
        return (totalAmount/totalNum);
    }  
    
    public Decimal getDocMan() {
        AggregateResult[] groupedResults = [SELECT COUNT(HTML_DocMan__c)totalSum FROM Customer_Health__c 
                                            WHERE Account__r.Handed_over_to_Support__c=True AND (HTML_DocMan__c='Yes - Successfully' OR HTML_DocMan__c = 'Yes - Piloting')];
       Decimal totalAmount = (Decimal)groupedResults[0].get('totalSum');
        return totalAmount;
    } 
   
    public Decimal getSpreads() {
        AggregateResult[] groupedResults = [SELECT COUNT(Spr__c)totalSum FROM Customer_Health__c 
                                            WHERE Account__r.Handed_over_to_Support__c=True AND (Spr__c='Yes - Successfully' OR Spr__c = 'Yes - Piloting')];
        Decimal totalAmount = (Decimal)groupedResults[0].get('totalSum');
        return totalAmount;
    }
    
    public Decimal getLogin() {
        AggregateResult[] groupedResults = [SELECT SUM(of_Login__c)totalSum FROM Customer_Health__c 
                                            WHERE Account__r.Handed_over_to_Support__c=True];
        Decimal totalAmount = (Decimal)groupedResults[0].get('totalSum');
        AggregateResult[] groupedResults2 = [SELECT COUNT(ID)totalN FROM Customer_Health__c 
                                                            WHERE Account__r.Handed_over_to_Support__c=True];
        Decimal totalNum = (Decimal)groupedResults2[0].get('totalN');
        return (totalAmount/totalNum);
    }
    
    public Decimal getNumRecords() {
        AggregateResult[] groupedResults = [SELECT COUNT(Id)total FROM Customer_Health__c
                                            WHERE Account__r.Current_Customer__c='Yes'];
        Decimal totalValue = (Decimal)groupedResults[0].get('total');
        return totalValue;
        
    }

    public Decimal getAVGTotalLoans() {
        AggregateResult[] groupedResults = [SELECT COUNT(Id)Total FROM nBIA__BI_Data__c 
                                            WHERE nBIA__Unique_Name__c = 'AS: Loans' 
                                            AND nBIA__Start_Date__c = YESTERDAY];
        Decimal totalCount = (Decimal)groupedResults[0].get('Total');

        AggregateResult[] groupedResults1 = [SELECT SUM(nBIA__Count__c)summ FROM nBIA__BI_Data__c 
                                            WHERE nBIA__Unique_Name__c = 'AS: Loans' 
                                            AND nBIA__Start_Date__c = YESTERDAY];
        Decimal totalSum = (Decimal)groupedResults1[0].get('summ');

        Decimal avgloans;
        if (totalCount != 0) {
        avgloans = totalSum / totalCount;
        } else {
            avgloans = 0;
        }

        return avgloans;
    }

    public Decimal getAVGTotalAccounts() {
        AggregateResult[] groupedResults = [SELECT COUNT(Id)Total FROM nBIA__BI_Data__c 
                                            WHERE nBIA__Unique_Name__c = 'AS: Accounts' 
                                            AND nBIA__Start_Date__c = YESTERDAY];
        Decimal totalCount = (Decimal)groupedResults[0].get('Total');

        AggregateResult[] groupedResults1 = [SELECT SUM(nBIA__Count__c)summ FROM nBIA__BI_Data__c 
                                            WHERE nBIA__Unique_Name__c = 'AS: Accounts' 
                                            AND nBIA__Start_Date__c = YESTERDAY];
        Decimal totalSum = (Decimal)groupedResults1[0].get('summ');

        Decimal avgaccounts;
        if (totalCount != 0) {
        avgaccounts = totalSum / totalCount;
        } else {
            avgaccounts = 0;
        }

        return avgaccounts;
    }

    public Decimal getAVGReportsRun() {
        AggregateResult[] groupedResults = [SELECT nBIA__Data_Source_Name__c, SUM(nBIA__Count__c)TheSUM 
                                            FROM nBIA__BI_Data__c 
                                            WHERE nBIA__Unique_Name__c = 'AS: Reports Run' 
                                            AND nBIA__Start_Date__c = LAST_N_DAYS:7 
                                            GROUP BY nBIA__Data_Source_Name__c];

        Decimal TotalCount = 0;
        Decimal TotalSum = 0;
        Integer i;

        for (i = 0; i < groupedResults.size(); i++) {
            TotalCount++;
            TotalSum += (Decimal)groupedResults[i].get('TheSUM');
        }

        Decimal avgreportrun;
        if (TotalCount != 0) {
            avgreportrun = TotalSum / TotalCount;
        } else {
            avgreportrun = 0;
        }
        return avgreportrun;
    }

    public Decimal getAVGDaysToClose() {
        AggregateResult[] groupedResults = [SELECT nBIA__Data_Source_Name__c, SUM(nBIA__Count__c)TheSUM, 
                                                    COUNT(Id)NumOfLoans FROM nBIA__BI_Data__c 
                                            WHERE nBIA__Unique_Name__c = 'AS: Loans Days To Close' 
                                            AND nBIA__Count__c <> 0 
                                            GROUP BY nBIA__Data_Source_Name__c];

        Decimal TotalCount = 0;
        Decimal TotalLoans = 0;
        Decimal TotalSum = 0;
        Decimal TotalAvgDays = 0;
        Integer i;

        for (i = 0; i < groupedResults.size(); i++) {
            TotalCount++;
            TotalSum = (Decimal)groupedResults[i].get('TheSUM');
            TotalLoans = (Decimal)groupedResults[i].get('NumOfLoans');
            TotalAvgDays += TotalSum / TotalLoans;
        }

        Decimal avgdays = TotalAvgDays / TotalCount;
        if (TotalCount != 0) {
            avgdays = TotalAvgDays / TotalCount;
        } else {
            avgdays = 0;
        }

        return avgdays;
    }
   
}

Here is my Test Class so far

@isTest(SeeAllData=true)
private class nCino_CustomerHealthTest {
	
	@isTest static void test_method_one() {
		// Implement test code
		CHANNEL_ORDERS__Customer__c customer = new CHANNEL_ORDERS__Customer__c(CHANNEL_ORDERS__Customer_City__c = 'Wilmington', 
												CHANNEL_ORDERS__Customer_Company_Name__c = 'The New Bank',	
												CHANNEL_ORDERS__Customer_Country__c = 'US',	
												CHANNEL_ORDERS__Customer_Org_ID__c = '00DG0000000jN8k', 
												CHANNEL_ORDERS__Customer_State__c = 'NC', 
												CHANNEL_ORDERS__Customer_Street__c = '11 Main Street', 
												CHANNEL_ORDERS__Customer_ZIP_Postal_Code__c = '28411');

		insert(customer);

		Account a = new Account(Name='The New Bank', Type='Customer', Industry='Bank', BillingState='NC', Customer__c = customer.Id, nCino_Version__c='1.64.4', Customer_Success_Manager__c = '005a0000007l9zJ', Primary_Product_Specialist__c = '005a000000AIahS', OwnerId = '005a0000009B00f');

		insert(a);

		sfLma__License__c license = new sfLma__License__c(sfLma__Account__c = a.Id, 
														sfLma__Install_Date__c = system.today(),
														sfLma__License_Type__c = 'Editable',
														sfLma__Package_Version__c = 'a0Ra000000Ib1Vx',
														sfLma__Status__c = 'Active',
														sfLma__Subscriber_Org_ID__c = '00DG0000000jN8k',
														sfLma__Used_Licenses__c = 2);
 
 		insert(license);

		Customer_Health__c c = new Customer_Health__c(Account__c=a.Id);

		insert(c);


		nCino_CustomerHealth theTest = new nCino_CustomerHealth();
		System.assert(theTest.cmSet.contains(c.Customer_Success_Manager__c));
		System.assert(theTest.amSet.contains(c.Account_Manager__c));
		System.assert(theTest.seSet.contains(c.Support_Engineer__c));





	}

}

It seems to not like the asserts when they worked before. Any Ideas?
Hi, I have an app that I'm developing that needs a report/dashboard built for visual representation of where these certain processes ("RPPs") are past along to various departments in our system.  These RPPs start at Dept. 1 and go to Dept. 9 through their 'journies'.  

What I need is a way to view the movement of these fields in an aggregated form.  So I can't just derive the information from the field itself in a report (because each one cooresponds with an individual record) but I need to be able to count the instances of each variable in that field, across the entire object, then report the levels of those various numbers in a visual representation.

So if Dept. 5 had 14 "RPPs" and Dept. 8 had 39 "RPPs" and Dept 9. had 4 "RPPs" then the report would show a bar-graph representing where the processes "RPPs" were "stuck" or built-up along the way.
Hello all,

I have a custom relation master/detail  (Qoutes__r) between Quote and QuoteLineItem.
I have a class where i need to get some data from Quote and QuoteLineItem but I'm getting this error:
 
Error: Compile Error: Didn't understand relationship 'Quotes__r' in FROM part of query call. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names. at line 35 column 16

Here my code:

LstQuotes = [SELECT q.id,q.QuoteNumber, q.Ad_Name__c,q.Type__c, q.Size__c,  q.Version__c, q.Bleed_Code__c,
   (Select Quotes__r.Advertiser_Account__c From Quotes__r)
   From Quote q
   where City_Code__c = :theId and q.Media_Name__c =: strMediaID];

The error is on this line (Select Quotes__r.Advertiser_Account__c From Quotes__r)

Thanks.
Hi have made a vf page and a custom button on campaign members. when i click on the cutom button i had given the function of executing javascript.

window.open('https://c.cs8.visual.force.com/apex/Mobiles?id={!Campaign.Id}','','scrollbars=no,menubar=no,height=600,width=800,resizable=yes,toolbar=yes,location=yes,status=yes');

its opening the new window but i want to open it in new tab. Please help
Hello
I am trying to write an vf email template as follows but keep getting this error message.  Can anyone shed any light as to why?  It is Line 84 (the section I have put in bold text) that is causing the error I think, but I don't know why?  I am learning as I go along, so please bear with me if it is something very obvious!!!  I appreciate any advice.  Thanks

<messaging:emailTemplate subject="A Business Priority 1 Incident #(Ref:IN:{!relatedto.Name}) has been Created for Service {!relatedTo.BMCServiceDesk__FKBusinessService__r.name}" recipientType="User" relatedToType="BMCServiceDesk__Incident__c">
<messaging:htmlEmailBody >
<html>
<body>

<apex:image url="https://c.cs18.content.force.com/servlet/servlet.ImageServer?id=015110000009VFN&oid=00D110000006XnK" width="100" height="30"/>

<p></p>
<h2>Coral Retail Priority 1 Business Notification  </h2>

<p></p>


<style type="text/css">
            body {font-family: Ariel; size: 12pt;}
            .left {FONT-FAMILY: Ariel; COLOR:#FFFFFF; BACKGROUND: #1669BC}
            .right {FONT-FAMILY: Ariel; COLOR:#000000; BACKGROUND: #C6DBEF}
            
            
td {
            border-width: 1px;
            padding: 1px;
            border-style: solid;
            border-color: #000000;
            
        }
        
    

        th { 
            color: #000000;
            border-width: 1px ;
            padding: 1px ;
            border-style: solid ;
            border-color: #000000;
          
        }
        

        </style>



<table>



<tr>
<td class = "left"><b>Incident Description</b></td>
<td class = "right">{!relatedto.BMCServiceDesk__incidentDescription__c}</td> 
</tr>

<tr>
<td class = "left"><b>Category</b></td>
<td class = "right">{!relatedto.BMCServiceDesk__FKCategory__r.name}</td> 
</tr>

<tr>
<td class = "left"><b>Service</b></td>
<td class = "right">{!relatedto.BMCServiceDesk__FKBusinessService__r.name}</td> 
</tr>

<tr>
<td class = "left"><b>Service Offering</b></td>
<td class = "right">{!relatedto.BMCServiceDesk__FKServiceOffering__r.name}</td> 
</tr>

<tr>
<td class = "left"><b>Incident Opened Date and Time&nbsp;&nbsp;</b></td>
<td class = "right"><apex:outputText value="{0,date,EEEE, MMMMM dd, yyyy 'at' HH:mm:ss z}"><apex:param value="{!relatedto.BMCServiceDesk__openDateTime__c + 0.041666666 }" /></apex:outputText></td> 
</tr>

<tr>
<td class = "left"><b>Incident Assigned to</b></td>
<td class = "right">{!relatedto.BMCServiceDesk__Additional_email_information__C}</td> 
</tr>

<tr>
<td class = "left"><b>Incident Number</b></td>
<td class = "right">{!relatedto.Name}</td> 
</tr>

<tr>
 <var="ih" value="{!relatedTo.BMCServiceDesk__Incident_Histories__r}">
<td class = "left"><b>Impact Analysis</b></td>
<td class = "right">{!ih.BMCServiceDesk__note__c}</td> 
</v>
</tr>

</table>
<p>
The IT Service Desk will provide an update on how the resolution of this P1 Incident is progresing in the next 30 minutes
</p>
<p>
<p>
</p>
<br></br>
<b>Regards,<br></br>
IT Service Desk</b>
</p>
<p>
<b>If replying to this email notification please do not change the subject line </b>
</p>
</body>
</html>

</messaging:htmlEmailBody>
</messaging:emailTemplate
I am trying to retrieve a child sobject's parent's field, but I'm getting an invalid field error. This is the code snippet:

The account Id would be the Id of an account with contacts, of course. 
List<Sobject> sobjectList = [SELECT Id, (SELECT Owner.Name, ownerId FROM Contacts) FROM Account where Id = '001E000000nG22yIAC' ];

List<Sobject> contList = sobjectList.get(0).getSobjects('contacts');
System.debug(loggingLevel.ERROR, 'cont list: ' + contList);
for (Sobject cont : contList) {

    String name = (String)cont.get('Owner.Name');
    System.debug(loggingLevel.ERROR, ' name: ' + name);
}

Is this a known limitation of Salesforce? 

  • August 08, 2014
  • Like
  • 0
I want to send file on box.com using salesforce1  mobile application so i need authentication  using salesforce1 give me some idea so i can solve this issue.
Hi,
I have some debug statements and checks that will send an email out when an Apex class fails on a DML operation (insert, update, delete). How can I create a string variable or array (whatever is most appropriate) that when the email is sent and opened in a Email Client (i.e. Outlook) there are line breaks where I want them to be?

Unsuccessful code I have tried:

try {
         insert list;
} Catch(DMLExceptiion dml) {
         String msg = '';
          for(Object ob : list){
                msg = msg + ob.Name + '\r\n';
          } 
          //at the end of the for loop, the msg variable has a list of all names of the object where there is a new line break after each name

        //structure of sendEmail method is SendEmail(Subject, Body);

        Email.SendEmail ('Test', msg);
}

------------------------------------------------------------------------
try {
         insert list;
} Catch(DMLExceptiion dml) {
         String msg = '';
          for(Object ob : list){
                msg = msg + ob.Name + BR();
          } 
          //at the end of the for loop, the msg variable has a list of all names of the object where there is a new line break after each name

        //structure of sendEmail method is SendEmail(Subject, Body);

        Email.SendEmail ('Test', msg);
}

  • August 06, 2014
  • Like
  • 0
Hi All,

I currently have a simple little trigger that is a "before insert" on Leads that looks up an account owner based on domain and transfers the Leads automatically to them.  The problem is that because of the order of operations, Triggers run before Web to Lead assignment rules and this causes the correctly assigned Lead (based on the trigger) to immediately be reassigned to to Web to Lead default Lead owner.  Here is the code:

trigger UpdateLeadOwner on Lead (before insert) {
    for (Lead leadInLoop : Trigger.new) {
   
if (leadInLoop.LeadSource != 'Contact Us' && leadInLoop.LeadSource != 'Reprint') {
    // Retrieve owner from Account record based on email domain name
    list <Account> acct = [Select OwnerId from Account WHERE Domain__c = :leadInLoop.Domain__c AND Owner.UserRoleId != '00E50000000t0Bf' Limit 2];
        if (acct.size() == 1) {

    //the next line is for debugging, to check that you are getting a result back from the query
    System.debug('account owner id is: ' + acct[0].OwnerId);
    leadInLoop.OwnerId=acct[0].OwnerId;
        }
    }
}
}

Since it is an order of operations issue, I decided to change the "before insert" to "after insert" and got the following error:

Error: Invalid Data.
Review all error messages below to correct your data.
Apex trigger UpdateLeadOwner caused an unexpected exception, contact your administrator: UpdateLeadOwner: execution of AfterInsert caused by: System.FinalException: Record is read-only: Trigger.UpdateLeadOwner: line 11, column 1

Anyone know how to fix this?  I'm happy with either correcting the "after insert" code or figuring out a way to stop the web to lead default assignment from kicking in.  Thanks!

Best,
Gita
Hello,
I found good presentation on Aura framework (http://jessealtman.com/2013/12/introduction-to-aura/ (http://jessealtman.com/2013/12/introduction-to-aura/" target="_blank)), installed it the Aura Note sample app but still struggle how to connect the app to Salesfoce as it is done in demo. Could you provide a sample how I can use the note application with Salesforce?
- Salesforce apex class does not understand the annotation @AuraEnabled  (sample from tutorial). How to enable it for coding on SF side or to apdate SF records from note application?
            
public with sharing class AuraConnect {
                       @AuraEnabled
                        public static void updateAnnualRevenue(String accountId, Decimal annualRevenue) {
                                   Account acct = [SELECT Id, Name, BillingCity FROM Account];
                                   acct.AnnualRevenue = annualRevenue;
                                   update acct;
                        }
}


- Should I use web services for this (get session, token and login in SF from Note app) in order to connect Aura app with SF dev organization (if yes, could you provide a sample as well)?

Thanks!
We have a trialforce organisation. Since morning we started getting "Destination URL not reset. The URL returned from login must be set" as we open developer console. As well as same issue is being occurred in Force.com IDE eclipse plugin. I am aware of this issue but don't know how it can be resolved in developer console as we don't have configuration acces to this level in Dev console.

Hi,

I want to register for Bangalore Event (Salesforce SummerOfHack) but it says developer is sold out. I've a team (developer, designer, secret weapon) and idea ready, but not able to register my developer.

Is it possible that we can register as a team or any other way so we can take our developer with us?

Any help would be appreciated.

I come to know that to update Apex component it is required to use Metdatacontainer object with ApexClassMember/ApexTrigger member. In Force.com Tooling API Dev guide given all examples to use Metadatacontainer and updating ApexClassMember and other members, but there all given examples uses SOAP API.

 

In REST API only syntax and hints are provided for creating, deleting, describe but no implementation. I am able create a Metadatcontainer object and receive its id as response and by same way ApexClassMember, but don't know how to use it with Metadatacontainer.

 

My Question is how to include and work with ApexClassMember with Metadatcontainer or associating ApexClassMember/ApexTriggerMember with a Metadacontainer object using REST API?

  • September 04, 2013
  • Like
  • 0
Global class BatchFirst1 implements database.batchable<sObject>{
    global database.querylocator start(database.batchablecontext BC){
       String acct = 'select id, name from account limit 10';
        return database.getQuerylocator(acct);
}
    global void execute(database.batchablecontext bc, list<account> acct){
    
        for(account acc : acct){
        
            acc.name= acc.name + 'checked';
        }
        update acct;
    }
     global void finish(Database.BatchableContext BC){
     Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
    
          mail.setToAddresses(new String[] {abcd@gmail.com});
       mail.setReplyTo('batch@acme.com');
       mail.setSenderDisplayName('Batch Processing');
        mail.setSubject('Batch Process Completed');
        mail.setPlainTextBody('Batch Process has completed');
 
        Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
}
      }
my intention is to send the email after completion of batch class finish method..
here i am getting error like   Error: Compile Error: unexpected token: '@' at line 16 column 58.
Please tell me the solution..
Thanks and regards,
Anji reddy.
Hi,

I'm using svg and use tags in a lightning component. I get the error:
 
Failed to save undefined: No COMPONENT named markup://use found

For the code: 
 
<svg aria-hidden="true" class="icon icon--large icon-standard-user">
                  			<use xlink:href="assets/icons/standard-sprite/svg/symbols.svg#user" />
                		</svg>

What am I doing wrong here?

Thanks!

I have System Administrator profile, still "Reset Security Token" is not visible for me. I have tried to receive the S.Token inmy mail box by resetting the password, still didnt receive any email. Can anyone suggest the workaround.
Hi Friends,

I have a requirement to Upload List of attachments from VF page in one click but iam getting a view state error on uploading a bulk data. so I tried useing "Remoting" even in remoting there are some limitation in passing the parameters and size. Iam passing the list of attachement each Attacmnent may consists of MB's of file. The challengeing part is there is a option to upload 50 attachments in one go also, there are 5 data points in which each data point may have 10 attachment to upload. based on the values the page rereders, the below is the image of the VF page.
Need Help Asap.
Thanks in Advance.

User-added image

Thanks in advance...
Hello Everyone,

I need support from a developed to help with Visual force with coding for a templete email ( having the triggered automatic email include, products purchased, date company etc)

Thank you
Hello All,

I've been assigned the task of creating a custom button on the Contact object to automagically convert Contacts to Person Accounts. I came across a great post online here:

http://www.x2od.com/2008/08/19/convert-between-business-and-person-accounts-b2b-b2c#comment-70797

... which seems like the direction I need to go. I did create the custom button to execute Java - here's the code:

{!REQUIRESCRIPT("/soap/ajax/13.0/connection.js")} 
var ContactObj = new sforce.SObject("Account"); 
ContactObj.Id = '{!Account.Id}'; 
ContactObj.RecordTypeId = '0120000000099Lo'; 
sforce.connection.update([ContactObj]); 
location.reload(true);

No syntax errors, created the button, put it on the Contact layout, created a test Contact, hit the button ... and ... zippo; nothing happens, not even an error message.

Anyone have a clue what I might be missing?

Thanks!
It is possible to have an extension for a custom controller? If yes can anyone share me the some basic code for how to call that both controller and extension in apex class ?

No more than 40 "Roll-Up Summary" fields are allowed per object.

We are getting the above error when we try to deploy existing and new Rollups.
 
We get the same error even if we try to deploy only existing rollups or only new rollups.
 
Only way it is working is by  manually creating the rollup fields and then deploy. As this is not a best practice, any suggestions on resolving this issue would be highly appreciated.
Hi All,

I need help creating an Apex Code to merge Leads created via Web to Lead once duplicate email address is detected. 
same thing with once a contact is created and if email address matches any of leads email address, Leads will be deleted.
Sound simple process but Salesforce don't have a declarative way to do it.

Thanks in advance.
Hello all, 
long time reader, first time poster.
I have a trigger that runs before update, gets some related users and sends them an email and then updates a field for a 'Sent
 email.
Good - When the records are manually changed (testing functionality), everything works great.
Bad - Test class produces the following error:
System.DmlException: Update failed. First exception on row 0 with id a0Ee0000006KoJZEA0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, EventSessionTrigger: execution of BeforeUpdate
caused by: System.EmailException: SendEmail failed. First exception on row 0; first error: INVALID_ID_FIELD, WhatId is not available for sending emails to UserIds.: []


There is documentation here (https://www.salesforce.com/us/developer/docs/apexcode/Content/apex_classes_email_outbound_single.htm#apex_Messaging_SingleEmailMessage_setWhatId) that says why the test error is coming up, BUT the question is why does it work in practice and not in the test?
The overall goal, would be to have it work in both. 
 
//Test class
@isTest
private class EventSessions_Test
{
  @testSetup static void testSetup()
  {
    Profile p =
      [SELECT Id FROM Profile
       WHERE Name = 'Customer Service Managers'];
    User u1 = new User(
      Alias = 'standt', Email = 'dhuckins@argyleforum.com',
      EmailEncodingKey = 'UTF-8', LastName = 'Testing',
      LanguageLocaleKey = 'en_US',
      LocaleSidKey = 'en_US', ProfileId = p.Id,
      TimeZoneSidKey = 'America/Los_Angeles',
      UserName = 'argyletestuser1@bar.com'
    );
    insert u1;
    EmailTemplate template = new EmailTemplate(
      Name = 'Test template',
      Subject = 'test subject',
      DeveloperName = 'Test_template_for_attendance_alerts',
      TemplateType = 'text',
      FolderId = '00l40000001pLA5AAM',
      IsActive = true
    );
    insert template;
  }
  @isTest static void test_method_one()
  {
    EmailTemplate template =
      [SELECT Id
       FROM EmailTemplate
       WHERE DeveloperName = 'Test_template_for_attendance_alerts'
                             LIMIT 1];
    User u1 =
      [SELECT Id
       FROM User
       WHERE Email = 'dhuckins@argyleforum.com'
                     LIMIT 1];
    Account account = new Account(
      Name = 'Test Account',
      Primary_Membership__c = 'CIO'
    );
    insert account;
    Contact contact = new Contact(
      FirstName = 'Test',
      LastName = 'Contact',
      AccountId = account.Id,
      Email = 'email@email.com'
    );
    insert contact;
    Events__c event = new Events__c(
      Name = 'Test Event ',
      Related_Membership__c = 'CIO',
      Event_Date__c = Date.today(),
      Programming__c = u1.id,
      Client_Name__c = account.Id,
      Is_there_a_dinner_with_this_meeting__c = 'No',
      Meeting_Type__c = 'Full Day'
    );
    insert event;
    Event_Session__c session = new Event_Session__c(
      Name = 'Test SEssion',
      Related_Event__c = event.Id,
      Email_Alert_Padding__c = 10,
      Email_Alert_Status__c = 'Scheduled',
      Start_Time__c = Datetime.now(),
      Email_Alert_Template__c = template.Id
    );
    insert session;
    Client_Project_Management__c module = new Client_Project_Management__c(
      Name = 'Test module',
      Account__c = account.Id
    );
    insert module;
    Campaign_Attribute__c attribute = new Campaign_Attribute__c(
      Project__c = event.Id,
      Staff_responsible_for_client_at_event__c = u1.Id, // send an email to this one
      Client_Project_Name__c = module.Id
    );
    insert attribute;
    Argyle_Alerts_Entry__c entry = new Argyle_Alerts_Entry__c(
      Account__c = account.Id,
      Interested_Account__c = account.Id,
      Contact__c = contact.Id,
      Related_Project__c = event.Id
    );
    insert entry;
    Attendee_Project_Junction__c attendee = new Attendee_Project_Junction__c(
      Attendance_Status__c = 'Attended',
      Attendee_Name__c = contact.Id,
      Attendee_Type__c = 'Other/Neutral',
      Project__c = event.Id
    );
    insert attendee;
    session.Email_Alert_Status__c = 'Sending';
    Test.startTest();
    update session; // line of error
    Test.stopTest();
    Event_Session__c check =
      [SELECT Id, Email_Alert_Status__c
       FROM Event_Session__c
       WHERE Id = :session.Id];
    System.assertEquals('Sent', check.Email_Alert_Status__c);
  }
}
 
//trigger handler
public class EventSessions extends fflib_SObjectDomain
{
  public EventSessions(List<Event_Session__c> records)
  {
    super(records);
  }

  public override void onBeforeUpdate(Map<Id, sObject> existingRecords)
  {
    EventSessionService.emailAlertsRouter(
      (List<Event_Session__c>)records,
      (Map<Id, Event_Session__c>)existingRecords
    );
  }

  public class Constructor implements fflib_SObjectDomain.IConstructable
  {
    public fflib_SObjectDomain construct(List<SObject> sObjectList)
    {
      return new EventSessions(sObjectList);
    }
  }
}
 
//service class
public class EventSessionService
{
  public static void emailAlertsRouter(
    List<Event_Session__c> sessions,
    Map<Id, Event_Session__c> oldSessions)
  {
    List<Event_Session__c> emailTriggers = new List<Event_Session__c>();
    for (Event_Session__c es : sessions)
    {
      if (es.Email_Alert_Status__c == 'Sending' &&
          oldSessions.get(es.Id).Email_Alert_Status__c == 'Scheduled')
      {
        emailTriggers.add(es);
      }
    }
    prepareAttendanceAlerts(emailTriggers);
  }

  public static fflib_SObjectUnitOfWork newInstance()
  {
    return new fflib_SObjectUnitOfWork(
             new Schema.SObjectType[]
             {
               Event_Session__c.SObjectType
             });
  }

  public static void prepareAttendanceAlerts(List<Event_Session__c> emailTriggers)
  {
    //we need a map of the event session and
    //the ids of users responsible for client
    //at that event
    fflib_SObjectUnitOfWork uow = newInstance();
    Set<Id> eventIds = new Set<Id>();
    for (Event_Session__c session : emailTriggers)
    {
      eventIds.add(session.Related_Event__c);
    }
    Set<Id> userIds = new Set<Id>();
    //Messaging.SingleEmailMessage[] emails = new Messaging.SingleEmailMessage[] {};
    for (Campaign_Attribute__c ca :
         [SELECT Id, Client_Project_Name__r.Account__c,
          Staff_responsible_for_client_at_event__c
          FROM Campaign_Attribute__c
          WHERE Project__c IN :eventIds])
    {
      userIds.add(ca.Staff_responsible_for_client_at_event__c);
    }
    for (Event_Session__c es : emailTriggers)
    {
      for (Id target : userIds)
      {
        Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
        email.setTemplateId(es.Email_Alert_Template__c);
        email.setSaveAsActivity(false);
        email.setTargetObjectId(target);
        email.setWhatId(es.Id);
        uow.registerEmail(email);
      }
      es.Email_Alert_Status__c = 'Sent';
      //uow.registerDirty(es);  //moved to onBeforeUpdate
    }
    uow.commitWork();
  }
}
 
Class	EventSessions_Test
Method Name	test_method_one
Pass/Fail	Fail
Error Message	System.DmlException: Update failed. First exception on row 0 with id a0Ee0000006KoJoEAK; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, EventSessionTrigger: execution of BeforeUpdate
caused by: System.EmailException: SendEmail failed. First exception on row 0; first error: INVALID_ID_FIELD, WhatId is not available for sending emails to UserIds.: []

Class.fflib_SObjectUnitOfWork.SendEmailWork.doWork: line 308, column 1
Class.fflib_SObjectUnitOfWork.commitWork: line 244, column 1
Class.EventSessionService.prepareAttendanceAlerts: line 78, column 1
Class.EventSessionService.emailAlertsRouter: line 31, column 1
Class.EventSessions.onBeforeUpdate: line 25, column 1
Class.fflib_SObjectDomain.handleBeforeUpdate: line 155, column 1
Class.fflib_SObjectDomain.triggerHandler: line 311, column 1
Class.fflib_SObjectDomain.triggerHandler: line 271, column 1
Trigger.EventSessionTrigger: line 18, column 1: []
Stack Trace	Class.EventSessions_Test.test_method_one: line 98, column 1



 
I am having an issue trying to pass inputField values from my VF page back to the controller using actionFunction with an onchange. The intent is that when the value in the inputField is changed by the user the new value is passed to the controller for processing.

As it stands now values for the inputFields are being passed but not the updated value of the field that was changed and triggered the onchange to fire. I have been over this for several hours and tried a few different methods of approaching this, none of which have been successful. Any help is appreciated.

VF Page:
<apex:pageBlockSection id="Detail" title="Product Detail">
    		<apex:inputField value="{!qli.Service_Location__c}" required="true"/> 		
    		<apex:inputField value="{!qli.Term__c}" required="true" label="Term (Months)"/> 
    		<apex:inputField value="{!qli.Service_Type__c}" required="true"/> 
    		<apex:inputField value="{!qli.Quantity}" required="true" id="quantity" onchange="updateQty();">
 				<apex:actionFunction name="updateQty" action="{!getdiscount}" rerender="listpricing" immediate="true">
					<apex:param name="xquantity" value="{!qli.Quantity}" assignTo="{!xquantity}"/>
					<apex:param name="xsalesMRC" value="{!qli.UnitPrice}" assignTo="{!xsalesMRC}"/>
					<apex:param name="xNRC" value="{!qli.NRC_is_Quantity_Sensitive__c}" assignTo="{!xNRC}"/> 
				</apex:actionFunction> 
			</apex:inputField>
</apex:pageBlockSection> 
<apex:pageBlockSection id="salesPricing" title="Sales Pricing">

    			<apex:inputField value="{!qli.UnitPrice}" id="CsalesMRC" label="Sales MRC" onchange="updateMRC();">
    			 	<apex:actionFunction name="updateMRC" action="{!getdiscount}" rerender="listpricing" immediate="true">
						<apex:param name="xquantity" value="{!qli.Quantity}" assignTo="{!xquantity}"/>
						<apex:param name="xsalesMRC" value="{!qli.UnitPrice}" assignTo="{!xsalesMRC}"/>
						<apex:param name="xNRC" value="{!qli.NRC_is_Quantity_Sensitive__c}" assignTo="{!xNRC}"/> 
					</apex:actionFunction> 
				</apex:inputField>	
    			<apex:inputField value="{!qli.NRC__c}" label="Sales NRC" required="true"/> 
    			<apex:outputField value="{!qli.TotalPrice}"/> 
    			<apex:outputField value="{!qli.Total_NRC__c}"/> 
    			<apex:outputField value="{!qli.Discount}" label="Discount from List"/>
    			<apex:inputField value="{!qli.NRC_is_Quantity_Sensitive__c}" onchange="updateNRC();">
    			 	<apex:actionFunction name="updateNRC" action="{!getdiscount}" rerender="listpricing" immediate="true">
						<apex:param name="xquantity" value="{!qli.Quantity}" assignTo="{!xquantity}"/>
						<apex:param name="xsalesMRC" value="{!qli.UnitPrice}" assignTo="{!xsalesMRC}"/>
						<apex:param name="xNRC" value="{!qli.NRC_is_Quantity_Sensitive__c}" assignTo="{!xNRC}"/>  
					</apex:actionFunction> 
    			</apex:inputField>
</apex:pageBlockSection>
<apex:pageBlockSection id="listpricing" title="List Pricing" >
</apex:pageBlockSection>



Controller Class:
 
public double quantity				{get; set;}
public decimal CsalesMRC			{get; set;}
public Boolean NRC 				{get; set;}

public void getDiscount() {
		//Get all variables from page
		string xNRC = ApexPages.currentPage().getParameters().get('xNRC');
			system.debug('@@@xNRC = ' + xNRC);
		NRC = boolean.valueOf(xNRC);	
			system.debug('@@@NRC = ' + NRC);
	
		string xSalesMRC = ApexPages.currentPage().getParameters().get('xsalesMRC');
			system.debug('@@@xSalesMRC = ' + xSalesMRC);
		CsalesMRC = double.valueOf(xSalesMRC);		
			system.debug('@@@CsalesMRC = ' + CsalesMRC);
						
		string xQuantity = ApexPages.currentPage().getParameters().get('xquantity');
			system.debug('@@@xQuantity = ' + xQuantity);
		quantity = decimal.valueOf(xQuantity);
			system.debug('@@@quantity = ' + quantity);
}

 
Hi,

I have used following code to send the Email template with attachment to two record type 1.Riser Service sheet 2.Sprinkler Riser working well, but Sprinkler when i enter the value to Email field i got ERROR: ​Error:Apex trigger OpportunityTriggers caused an unexpected exception, contact your administrator: OpportunityTriggers: execution of AfterUpdate caused by: System.EmailException: SendEmail failed. First exception on row 0; first error: UNKNOWN_EXCEPTION, List has no rows for assignment to SObject: []: Class.OpportunityTriggerHandler.EmailAttachment: line 1170, column 1

Please refer the following code
============================
  Private void SendEmailAttachment(Map<Id,Opportunity> newOppMap,Map<Id,Opportunity> oldOppMap){
        List<id> listMSSIds=new List<Id>();    // list of Mechanical Service Sheet Id
        String templateName;
        List<String> mailId;
        System.Debug('--------Starting----------');
        for(Opportunity opp:newOppMap.values()){        //Collecting the Mechanical Service Sheet ids from the Triggered Opportunities
            if(opp.Mechanical_Service_Sheet__c != NULL){
                listMSSIds.add(opp.Mechanical_Service_Sheet__c);
            }              
        }
        for(Opportunity opp:[select id,MSS_Service_Type__c,Copy_Email_for_Invoice__c,ownerId,Mechanical_Service_Sheet__c,
                         Accounts_Approved_Rejected__c,Management_Approved_Rejected__c,Service_Approved_Rejected__c ,Date_Copy_Invoice_Sent__c,
                         Priced__c , Manually_Sage_Invoiced__c,Manual_Invoicing__c,Invoice_email_to__c ,Email_for_Copy_SS_RS_SW__c
                         from Opportunity where id=:newOppMap.keyset()]){
                         
            if(opp.Copy_Email_for_Invoice__c!=NULL && opp.MSS_Service_Type__c!=NULL &&
                     (((!opp.Manual_Invoicing__c) && opp.Manually_Sage_Invoiced__c=='No') 
                     || ((!opp.Manual_Invoicing__c) && opp.Manually_Sage_Invoiced__c==NULL) || 
                     ((opp.Manual_Invoicing__c) && opp.Manually_Sage_Invoiced__c=='No')) && 
                   (opp.Copy_Email_for_Invoice__c!=oldOppMap.get(opp.id).Copy_Email_for_Invoice__c || opp.Manually_Sage_Invoiced__c!=oldOppMap.get(opp.id).Manually_Sage_Invoiced__c
                ||opp.Manual_Invoicing__c!=oldOppMap.get(opp.id).Manual_Invoicing__c)){
                mailId = new List<String>();
                templateName='Copy Invoice and MSS Cert';
                mailId.add(opp.Copy_Email_for_Invoice__c);
                EmailAttachment(templateName,listMSSIds,opp,mailId,false);
            }
            system.debug('Opportunity==='+opp);
            system.debug('Old Opp===='+oldOppMap.get(opp.id));
             if(opp.Accounts_Approved_Rejected__c =='Approved' && opp.Management_Approved_Rejected__c =='Approved' &&
                     opp.Manually_Sage_Invoiced__c!='Yes' && opp.Service_Approved_Rejected__c =='Approved' &&  opp.Priced__c =='PRICED' && opp.MSS_Service_Type__c!=NULL &&
                     (((!opp.Manual_Invoicing__c) && opp.Manually_Sage_Invoiced__c=='No') || ((!opp.Manual_Invoicing__c) && opp.Manually_Sage_Invoiced__c==NULL) || ((opp.Manual_Invoicing__c) && opp.Manually_Sage_Invoiced__c=='No')) && 
                     (opp.Accounts_Approved_Rejected__c!=oldOppMap.get(opp.id).Accounts_Approved_Rejected__c || opp.Management_Approved_Rejected__c != oldOppMap.get(opp.id).Management_Approved_Rejected__c ||
                     opp.Service_Approved_Rejected__c!=oldOppMap.get(opp.id).Service_Approved_Rejected__c || opp.Priced__c!= oldOppMap.get(opp.id).Priced__c ||
                     opp.Manually_Sage_Invoiced__c!=oldOppMap.get(opp.id).Manually_Sage_Invoiced__c)){
                templateName='MSS Opps Invoice';
                mailId = new List<String>();                
                mailId.add(opp.Invoice_email_to__c);                
                EmailAttachment(templateName,listMSSIds,opp,mailId,true);
                
            } 
            if(opp.Mechanical_Service_Sheet__c != NULL && opp.Email_for_Copy_SS_RS_SW__c != NULL &&
               (opp.Mechanical_Service_Sheet__c !=oldOppMap.get(opp.id).Mechanical_Service_Sheet__c 
               ||opp.Email_for_Copy_SS_RS_SW__c !=oldOppMap.get(opp.id).Email_for_Copy_SS_RS_SW__c ) ){
                templateName='Fire Supresion Sheet from Opp';
                mailId = new List<String>();                
                mailId.add(opp.Email_for_Copy_SS_RS_SW__c);                
                EmailAttachment(templateName,listMSSIds,opp,mailId,false);
                
            } 
            
        } 
        
    }     
    
 Private void EmailAttachment(String templateName,List<id> listMSSIds,Opportunity opp,List<String> toAddress, Boolean isOriginal ){
        // get The Email Template Id 
        EmailTemplate template = [Select id,name,subject from EmailTemplate 
                                  where name =:templateName];
              
        //Added the below code to prevent the mail to owner
        Contact tempContact  = new Contact();
        tempContact.LastName ='TestLast';
        tempContact.firstName = 'Testname';
        tempContact.email = toAddress[0];
        tempContact.Account = [select id, name from Account limit 1];
        Insert tempContact;

        //get The List Of Attachments In Mechanical Service Sheet
        List<Attachment> attachmentList=new List<Attachment>();
        if(opp.MSS_Service_Type__c=='Riser Service Sheet' || opp.MSS_Service_Type__c=='Sprinkler Service Sheet' ){
            attachmentList=[select name,body from Attachment Where ParentId IN:listMSSIds];
        }
        efaList = new List<Messaging.Emailfileattachment>();
        email = new Messaging.SingleEmailMessage();
        email.setTemplateId(template.id);
        //email.setTargetObjectId(opp.ownerId);
        email.setTargetObjectId(tempContact.id);
        email.setWhatId(opp.Id);
        email.setSaveAsActivity(false);
        
        if(isOriginal){email.setCCAddresses(new list<String>{'Sundhar.mks@gmail.com'});}
        System.Debug('--------attachmentList----------'+attachmentList);
        for(Attachment a:attachmentList){
            efa= new  Messaging.Emailfileattachment(); 
            efa.setFileName(a.name);
            efa.setBody(a.body);
            efaList.add(efa);
                         
        }
       email.setFileAttachments(efaList);
       
        List<Messaging.SingleEmailMessage> lstMsgs = new List<Messaging.SingleEmailMessage>();
        lstMsgs.add(email);
        
        Messaging.sendEmail(lstMsgs);
        
        //Delete the temp contact.
        delete tempContact;
        System.Debug('--------Ending----------'+lstMsgs); 
                                                                 
    } 


Thanks.
Hi,

If I decalre a variable in the first part of my class outside any of the methods, it should be available within all of my methods yes?  But for some reason that's not working here, I don't understand what's wrong.  There must be somethign I'm missing

Thanks,
public class ContactReclassTest {
    
    String confirstName;
    String conlastName;
    List<Contact> conList = New List<Contact>();  // this should be seen by within all methods yes?
    
    ContactReclassTest() {
        conFirstName = 'Mathew';
        conlastName = 'Andresen';
        
    }
   
    
    public static void createContacts() {
        List<Contact> conList = New List<Contact>();  // If I don't put this in it says the variable doesn't exist
    for(Integer i = 0; i < 5; i++) {
        Contact con = new Contact(FirstName = 'Mathew', LastName = ('Andresen'+ i) );  //can't find the other strings I declared either
        conList.add(con);
    }
        insert(conList);
    
    }
}



 
I have a working trigger that updates a lookup field from a zipcode object when the zipcode name = the listing zip code on the lead.  However, I need to add an additional restriction, where the metro__c field on the lead = the metro__c field on the zip code table, and I'm not sure how to do this.  How would I add this restriction?

The working trigger is below:

trigger UpdateListingZip on Lead (before insert, before update) {
    Set<String> ListingZips = new Set<String>();

    for( Lead l : trigger.new ) {
        if( l.listing_zip_code__c != null && l.LAG_Offered__c!=TRUE && l.DTA_Lead__c !=TRUE) {
            ListingZips.add( l.listing_zip_code__c );
                        
 }
    }            

        // Now we have a set of unique zipcodes we want to verify, time to look them up.
    // I plan to build a map of the "match field" -> "full reference object"

    Map<String, zip_codes__c> MatchZips = new Map<String, zip_codes__c>();

    for(zip_codes__c obj : [SELECT  Id,
                                           zipcode__c
                                            FROM    Zip_Codes__c
                                            WHERE     zipcode__c IN :ListingZips] ) {MatchZips.put( obj.zipcode__c, obj );
    }
    // We have all the reference data we need, last loop on the each lead

    for( Lead l : trigger.new ) {

        if( l.listing_zip_code__c != null ) { // there IS a countrylist entry to deal with... so...

            if( MatchZips.containsKey(l.listing_zip_code__c) ) { l.Zip_Code_Lookup__c = MatchZips.get(l.listing_zip_check__c).ID; }}
}
}
Can any one let me know how to insert bulk records using Apex coding. Here is the requirement.

I need to insert 10 Account records and for each Account record need to associate 2 Contacts and 2 Opportunities. Please let me know the code to be executed from Developer Console.

At last we should have 10 Account records, 20 Contacts and 20 Opportunities.
Hi All,

I am working on case where a scheduled batch calling a future method/class. As salesforce restricts the future call from batch , i am looking for any other alternative or workaround for this .

I need to use the future call  in schedule batch because , the dml operation i do in future call is on configuration object, performing dml operation on configuration objects causes us Mixed DML exception . To over come this error we need to use the future call.

Any light on this is of great help.
Hi, I'm trying to query on 3 objects with different relationships and need some help. The "base" of my query is a Receipt object, which has a lookup to a Gift object. The Gift object then has child records in an Allocation object. What  I'd like to do is query Receipt data while listing the Allocations associated with the Gift on the receipt.

I can query the Receipt and Gift data like so:
SELECT Id, causeview__Gift__r.Id FROM causeview__Receipt__c

And query the Allocation child records from the gift:
SELECT Id, (SELECT Id FROM causeview__Gift_Allocations__r) FROM causeview__Gift__c

But I'm not sure how to put the 2 together to get everything 1 query.

Thanks for any help!
Hey,

Ive created a two-dimension array and initialized it like that:

        list<list<integer>> two_d_array = new list<list<integer>>();
        integer[] one_d_array = new list<integer>();
       
        for(integer i=0 ; i<d2_size ; i++){
            for(integer j=0 ; j<d1_size ; j++){
                one_d_array.add(0);
            }
            two_d_array.add(one_d_array);
        }
i wanna approach a direct cell like that:
   two_d_array[2][3] = 1289;
    or (do the same thing)
    two_d_array.get(2).set(3, 1289);

The problem is, by doing it it assign all column [3] as 1289.
The array will be like:
[0][3] = 1289
[1][3] = 1289
[2][3] = 1289
etc.

So how can i approach a direct cell. A specific one, not the all column.

Thx a lot!

Hi guys,

I am creating my own REST API.
I was able to succesfully do @HttpPost

I am now working on @HttpGet and getting the following error from my curl request:

[][{"message":"An unexpected error occurred. Please include this ErrorId if you contact support: 22838684-12976 (2061038835)","errorCode":"UNKNOWN_EXCEPTION"}]

What does this mean and how can you guys use it to help me get my API running?

Also, how can i test and debug my Web service without having to contact support every time?
Here is my curl command:

curl --request GET -H 'Authorization: OAuth 00Do0000000KyIg!ASAAQAUD3IsQkLkjFArVq6RvMadk41WNticN9ZgGHa7Iozs0euGa9XVG7LMEysX6C_SIVcCNrr4NA5a62k2lrGgNTLtyXepJ' 'https://na17.salesforce.com/services/apexrest/QuotePreview?quoteId=a0Fo00000026dOXEAY'

and Php code used to run a get:

$quoteId = 'a0Fo00000026dOXEAY';
  $quoteurl = "https://na17.salesforce.com/services/apexrest/QuotePreview?quoteId=".$quoteId;
  $curl = curl_init();
  curl_setopt($curl, CURLOPT_URL, $quoteurl);
  curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($curl, CURLOPT_HTTPHEADER,
          array("Authorization: Bearer $accessCode",
           "Content-type: application/json"));
  curl_setopt($curl, CURLOPT_HTTPGET, true);

  $json_response = curl_exec($curl);


Hi all,

I have a currecy field and needs to convert it into words.
Ex: Amount : $ 1,10,521
 It should be converted into text as "1 lakh 10 thousand five hundred and twenty 1 dollars only".

Plese suggest me

String JobName = 'job8'+recId;
           
           
           
            CronTrigger cjd = [SELECT Id FROM CronTrigger where CronJobDetail.Name=:jobname];
            if(cjd!=null){
           
                delete cjd;
           
            }

how can we delete schedule job ?

Over the last several days my organizations has been experiencing intermittent  issue with logging into Salesforce. Access issue appear across a number of browsers including IE9, Firefox 29 and Chrome 36. For our organization we use a custom url to access Salesforce and when attempting to sign in via the url the page often displays a message regarding a problem with a redirection issue. While we do use a single sign on (SAML) with the custom url, other services that make use of the single sign are all working, and there are even times when the single sign on for Salesforce is working properly. The problem is most consistent with IE9 in that upon attempting to access the page it returns a simple page cannot be displayed, within firefox the message offers the following, the page isn't redirecting properly, firefox has detected that the server is redirecting requests for this address in a way that will never complete. This problem can sometimes be caused by disabling or refusing to accept cookies., and lastly the results for  chrome are this page has a redirect loop.
Support via cases with Salesforce has been extremely disappointing as they continue to reclassify my case and close the call, so I am reaching out to see if others have had the issue and might offer some advice.

Dear Users,

 

If you must buildi a dynamic SOQL query, something like below, 

qryString += 'AND ' +filterField+ ' LIKE \'' +filterValue+ '%\' ';

 atleast have getter and setter methods defined something like this

    public String filterValue {
        get{return filterValue;}
        set{
        	if(value!=null)
            	filterValue = String.escapeSingleQuotes(value);
        	else
            	filterValue='';            
        }
    }
    public String filterField {
        get{return filterField;}
        set{
        	if(value!=null)
            	filterField = String.escapeSingleQuotes(value);
        	else
            	filterField ='';          
        }
    }

 This would prevent SOQL injection if user enters something like ' OR 1==1;/*  in the VF page. 

 

Feedback / Comments welcome. 

 

regards

SF Partner