• debra
  • NEWBIE
  • 250 Points
  • Member since 2012
  • PRN

  • Chatter
    Feed
  • 5
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 37
    Questions
  • 72
    Replies
Trying to create VF Page that will show a list of Opportunities and when user clicks on a row in the list a section below would display the OpportunityLineItems for the selected row in the opportunity list.

Thought was to have a variable in the controller for selected OpportunityID and use this to query the OpportunityLineItem list for the 2nd table however not clear how to set this ID value when user clicks on a row in the opportunity table.    Thinking add action on a column in the row onclick{!setOppID}  but now sure to how to access the selected rows data - I do have a column that contains the ID value.
Getting the error bad value for restricted picklist field: F2F while sending email from sandbox.

In sandbox Enhanced email is enabled.

Did someone faced the same issue and found the solution (what need to be done to resolve this).

Error
I am VERY new to LWC development and having issue opening a previously created LWC from my Org using Visual Studio Code.   I do not have this code yet in any folder on my system just want to connect to the org and pull down the code for pre-existing LWCs.
I did install Salesforce in Visual Studio Code but not sure how to use it once it's installed

Any tips are appreciated.  
Most of my old experience was with Apex/VF and Eclipse IDE.
I am trying to create a new record on a separate object (new contract on Contract object from Proposal object). And I am receiving this error FIELD_INTEGRITY_EXCEPTION: Account ID: id value of incorrect type. 
Not sure how to diagnose this one. 
Hi community,

I created a custom object for a particular group of people, let's say they are something like "customers". I'm working on an "Enterprise" version with the "community" feature enabled, and I just created my first "community".

I'd like to understand how I can grant my "customers" access to the community. Somebody told me that every "customer" needs to be linked to a "user account", but I'm unsure how to do that.

I could really need a hand here...
If i need to creat an Order , I need to first creat an Account and then assign the AccountId to the Order, like the following
 Account a = new Account();
 a.Name = 'Test';
 insert a;    

 Order order = new Order(     
        AccountId = a.Id,
        Status='Draft',
        EffectiveDate = Date.today());
 insert order;

Is there a way to create an Order and the required fields will be populated including the AccountId that is linked to the Account?
Reason is that I am looking at dynamically crating tests for my SObjects.
So if i have a trigger on Order (after insert) , I want to create a test for this but do it through a dynamic templating that I can use for al SObjects .

Thanks
Hello - I'm running into an error when I run my test class. Below is the code from the class. The test class says line 17 (below) is causing too many soql queries.  The query looks for opporutnity line items where the OpportunityId is in the mapOfOppIds maps. Could you please let me know why this soql error is happening?
  1.  //Map of new opp values
  2.         Map<Id, Decimal> mapOfOppIds = new Map<Id, Decimal>();
  3.         Map<Id, Decimal> mapOfUpdatedOppIds = new Map<Id, Decimal>();
  4.         
  5.         for(Opportunity newOpp : newUpdatedOpp) {
  6.             if(mapOfOldOppArr.get(newOpp.Id) != mapOfUpdatedArr.get(newOpp.Id)
  7.                && newOpp.Renewed_Opportunity__c == true){
  8.                 mapOfOppIds.put(newOpp.Originating_Opp_Id__c, newOpp.ARR__c);
  9.                 mapOfUpdatedOppIds.put(newOpp.Id, newOpp.ARR__c);
  10.                     }        
  11.             }
  12.         
  13.         system.debug('values in mapOfOppIds ' +mapOfOppIds);
  14.         system.debug('values in mapOfUpdatedOppIds ' +mapOfUpdatedOppIds);
  15.         
  16.         //Query Original Opp Line Items
  17.          List<OpportunityLineItem> oli = [Select Id, OpportunityId, UnitPrice, Originating_OLI_Id__c FROM OpportunityLineItem
  18.                                               WHERE OpportunityId IN :mapOfOppIds.keySet()];
  19.         
  20.         System.debug('Opp Line Items from original opp ' +oli);
I have a simple requirement to retrieve the error routing email address for a specific email service.  I have not found a single SOQL statement to retrieve the value based on the Apex class assigned to the email service.  Normal relationship field query methods do not seem to work with the ApexClassId field on the emailServicesFunction object.
Here are the two queries that will get the value I need but would like to understand why a specific relationship field does not query as expected so that this could be done with one statement!

1st SOQL: select Id from Apexclass where name = 'MyInboundEmailHandlerClass';
2nd SOQL taking the result from the 1st:  select errorRoutingAddress from emailServicesFunction  where ApexClassid = '01p6C000000LicNQAS'

Thanks!
Hi 

i want increase test code coverage for below class


public with sharing class CommissionEditorController {

    Map<integer,String> mapMonth = new Map<integer, String>{1=>'JAN',2=>'FEB',3=>'MAR',4=>'APR',5=>'MAY',6=>'JUN',7=>'JUL',8=>'AUG',9=>'SEP',10=>'OCT',11=>'NOV',12=>'DEC'};
    Map<String,integer> mapMonthString = new Map<String,integer>{'JAN'=>1,'FEB'=>2,'MAR'=>3,'APR'=>4,'MAY'=>5,'JUN'=>6,'JUL'=>7,'AUG'=>8,'SEP'=>9,'OCT'=>10,'NOV'=>11,'DEC'=>12};
    List<String> listMonthString = new List<String>{'APR','MAY','JUN','JUL','AUG','SEP','OCT','NOV','DEC','JAN','FEB','MAR'};
    public Commission__c commissionRec {get;set;}
    public List<Commission__c> listCommessionRecToBeUpserted;
    public String currentFinantialYear = '';
    public Boolean showSection {get;set;}
    public Boolean showMessage {get;set;}
    public String fieldSetAPIName = '';
    public String payrollNumber = '';
    public String urlCommissionTemplate {get;set;}
    public Blob contentFile {get; set;}
    public String nameFile {get; set;}
    public List<List<String>> parsedCSV = new List<List<String>>();
    public List<Commission__c> cObjsToInsert = new List<Commission__c>();
    
    
    public CommissionEditorController(){
        showSection = false;
        showMessage = false;
        commissionRec = new Commission__c();
        Date currentDate = Date.today();
        Integer month = currentDate.Month();
        Integer year = currentDate.Year();
        commissionRec.Month__c = '' + mapMonth.get(month - 1);
        currentFinantialYear = ((month - 1)>3)?(year+' - '+((year+1)+'').subString(2)):(''+(year-1)+' - '+(year+'').subString(2));
        commissionRec.Year__c = currentFinantialYear;
        urlCommissionTemplate = System.Label.CommissionTemplateLink;
    }
    
    public void getUserTeam(){
        String userName = System.currentPageReference().getParameters().get('userId');
        User userRec = [Select Id, Name, Team__c, Payroll_Number__c from User where Name =: userName limit 1];
        payrollNumber = userRec.Payroll_Number__c;
        String fieldSetName = userRec.Team__c;
        CommissionTeamFieldSet__c fieldset = CommissionTeamFieldSet__c.getValues(fieldSetName);
        fieldSetAPIName = fieldset.FieldSet_Name__c;
        system.debug('payrollNumber ====='+payrollNumber );
        showSection = true;
        try{
            Commission__c oldRec = Database.query(getCommission(commissionRec.Month__c, commissionRec.Year__c, userRec.Id));
            if(oldRec != Null){
                System.debug('oldRec =='+ oldRec);
                commissionRec = oldRec;
            }
            else{
                commissionRec = commissionRec;
            }
        }
        Catch(Exception e){
            commissionRec = commissionRec;
        }
    }
    
    public List<Schema.FieldSetMember> getFields() {
        return getFieldSet(fieldSetAPIName, 'Commission__c');
    }

    public String getCommission(String month, String year, Id userId) {
        String query = 'SELECT ';
        for(Schema.FieldSetMember f : this.getFields()) {
            query += f.getFieldPath() + ', ';
        }
        query += 'Id, Name, Month__c, Year__c, User__c, OTC__c, Monthly_OTC__c, Cumulative_OTC__c, Weighted_Average_Performance__c, Accelerated_Decelerated_WA_Performance__c, Cumulative_Payment_Earned__c, Previous_Commission_Paid__c, Payment_Due__c, Accelerator_Bank__c FROM Commission__c';
        query += ' where Month__c =\''+month+'\' And Year__c =\''+year+'\' And User__c =\''+userId+'\' LIMIT 1';
        return query;
    }
    
    public List<Schema.FieldSetMember> getFieldSet(String fieldSetName, String ObjectName)
    {
        System.debug('fieldSetAPIName=fieldSetName==='+fieldSetName);
        Map<String, Schema.SObjectType> GlobalDescribeMap = Schema.getGlobalDescribe(); 
        Schema.SObjectType SObjectTypeObj = GlobalDescribeMap.get(ObjectName);
        Schema.DescribeSObjectResult DescribeSObjectResultObj = SObjectTypeObj.getDescribe();

        Schema.FieldSet fieldSetObj = DescribeSObjectResultObj.FieldSets.getMap().get(fieldSetName);
        System.debug('fieldSetObj.getFields()==='+fieldSetObj.getFields());
        return fieldSetObj.getFields(); 
    } 
        
    public pageReference save(){
        if(commissionRec.Id != Null){
            upsert commissionRec;
            PageReference page1 = new PageReference('/'+commissionRec.Id);
            return page1;
        }
        else{
            commissionRec.Name = payrollNumber + commissionRec.Month__c + commissionRec.Year__c;
            commissionRec.ExternalKey__c = commissionRec.Name;
            commissionRec.Payroll_Number__c = payrollNumber;
            insert commissionRec;
            PageReference page1 = new PageReference('/'+commissionRec.Id);
            return page1;
        }
        return null;
    }
    
    public pageReference reset(){
        PageReference pg = new PageReference(System.currentPageReference().getURL());
        pg.setRedirect(true);
        return pg;
    }
    
    public pageReference insertCommission(){
        listCommessionRecToBeUpserted = new List<Commission__c>();      
        Integer rowCount = 0;
        Integer colCount = 0;
        system.debug('=============contentFile-1-'+contentFile);
        if(contentFile == null){
            system.debug('=============contentFile-2-'+contentFile);
            Apexpages.addMessage( new Apexpages.message(Apexpages.Severity.ERROR, System.Label.CommissionFileNotFound)); 
        }
        else if (contentFile != null){
            system.debug('=============contentFile-3-'+contentFile);
            String fileString = contentFile.toString();
            system.debug('========fileString'+fileString);
            contentFile = null;
            parsedCSV = Commission_ParserUpload.parseCSV(fileString, false);
            rowCount = parsedCSV.size();
            for (List<String> row : parsedCSV){
                if (row.size() > colCount){
                    colCount = row.size();
                }
            }        
            cObjsToInsert = Commission_ParserUpload.csvTosObject(parsedCSV,'Commission__c') ;       
            if(cObjsToInsert.size() > 0){
                for(Commission__c coRec : cObjsToInsert){
                    Commission__c newRec = new Commission__c();
                    newRec = coRec;
                    newRec.Name = coRec.Payroll_Number__c + coRec.Month__c + coRec.Year__c;
                    newRec.ExternalKey__c = newRec.Name;
                    listCommessionRecToBeUpserted.add(newRec);
                }
            }
            if(listCommessionRecToBeUpserted.size() > 0){
                upsert listCommessionRecToBeUpserted ExternalKey__c;
                showMessage = true;
            }
        }
        return null;
    }
}



test class is---------------------
================================
@isTest(SeeAllData=true)

public class CommissionEditorControllerTest{
 
    static testMethod void saveNewTest() {
        List<Profile> lstPortalProfiles = [ Select id, usertype from Profile where name = 'System Administrator'];
        User objUser = new User( email='test-user@fakeemail.com', profileid = lstPortalProfiles[0].id, UserName='test-user@email.com', alias='tuser1', 
                                       CommunityNickName='tuser1', TimeZoneSidKey='America/New_York', LocaleSidKey='en_US', EmailEncodingKey='ISO-8859-1', LanguageLocaleKey='en_US', 
                                       FirstName = 'Test', LastName = 'User', isActive=true,Payroll_Number__c = '12345',Team__c='Direct Large SME AM');
        insert objUser;
        CommissionEditorController test1 = new CommissionEditorController();    
        test1.commissionRec.Month__c = 'Jun';
        ApexPages.currentPage().getParameters().put('userId', objUser.Name);
        //test1.getUserTeam();
        test1.save();   
    }
    
    static testMethod void saveOldTest() { 
        List<Profile> lstPortalProfiles = [ Select id, usertype from Profile where name = 'System Administrator'];
        User objUser = new User( email='test-user@fakeemail.com', profileid = lstPortalProfiles[0].id, UserName='test-user@email.com', alias='tuser1', 
                                       CommunityNickName='tuser1', TimeZoneSidKey='America/New_York', LocaleSidKey='en_US', EmailEncodingKey='ISO-8859-1', LanguageLocaleKey='en_US', 
                                       FirstName = 'Test', LastName = 'User', isActive=true,Payroll_Number__c = '12345',Team__c='Direct Large SME AM');
        insert objUser;
        CommissionEditorController test1 = new CommissionEditorController();    
        test1.commissionRec.Month__c = 'Jun';
        ApexPages.currentPage().getParameters().put('userId', objUser.Name);
        //test1.getUserTeam();
        test1.save();

        CommissionEditorController test2 = new CommissionEditorController();
        //Commented below for ChangeSet exception
        //test1.commissionRec.Month__c = 'Jun';
        test2.commissionRec.Month__c = 'Jan';
        ApexPages.currentPage().getParameters().put('userId', objUser.Name);
        //test2.getUserTeam();
        test2.save();
    }
    
    static testMethod void resetTest() {  
        PageReference pageRef = new PageReference('/CommissionEditorPage');
        Test.setCurrentPage(pageRef);
        
        CommissionEditorController test1 = new CommissionEditorController();
        test1.reset();  
    }
    
    static testMethod void uploadTest() {       
        CommissionEditorController test1 = new CommissionEditorController();
        String csvStr = 'Month__c,Payroll_Number__C,Year__c\n'+'AUG,12345,2015 - 16';
        test1.contentFile = Blob.valueOf(csvStr);  
        test1.insertCommission();
    }
    
    static testMethod void dashboardTest() {
        List<Profile> lstPortalProfiles = [ Select id, usertype from Profile where name = 'System Administrator'];
        User objUser = new User( email='test-user@fakeemail.com', profileid = lstPortalProfiles[0].id, UserName='test-user@email.com', alias='tuser1', 
                                       CommunityNickName='tuser1', TimeZoneSidKey='America/New_York', LocaleSidKey='en_US', EmailEncodingKey='ISO-8859-1', LanguageLocaleKey='en_US', 
                                       FirstName = 'Test', LastName = 'User', isActive=true,Payroll_Number__c = '12345',Team__c='Direct Large SME AM');
        insert objUser;
        
        List<User> lstUser = [SELECT Id, Name, Payroll_Number__c, Team__c FROM User where Name = :objUser.Name];
        Commission__c obj1 = new Commission__c();
        /*Map<integer,String> mapMonth = new Map<integer, String>{1=>'JAN',2=>'FEB',3=>'MAR',4=>'APR',5=>'MAY',6=>'JUN',7=>'JUL',8=>'AUG',9=>'SEP',10=>'OCT',11=>'NOV',12=>'DEC'};
        Date currentDate = Date.today();
        Integer month = currentDate.Month();
        Integer year = currentDate.Year();
        mapMonth.get(month - 1);
        String currentFinantialYear = ((month - 1)>3)?(year+' - '+((year+1)+'').subString(2)):(''+(year-1)+' - '+(year+'').subString(2));
        */

        obj1.Month__c = 'JUL';
        if(lstUser != null && lstUser.size() > 0){
            obj1.OwnerId = lstUser[0].Id;
        }
        
        String currentFinancialYear = '';
        Date currentDate = Date.today();
        string namefile='';
        Integer currentMonth = currentDate.Month();
        Integer month = 7;
        Integer year = currentDate.Year();
        if(month > currentMonth  || month <= 3){
            currentFinancialYear = ''+(year-1)+' - '+(year+'').subString(2);
        }
        else{
            currentFinancialYear = year+' - '+((year+1)+'').subString(2);
        }
        
        
        obj1.Year__c = currentFinancialYear;
        obj1.Payroll_Number__c = '12345';
        insert obj1;
        
        System.runAs(objUser){
          CommissionDashboardController test1 = new CommissionDashboardController();
            CommissionDashboardController.listCommissions();
            CommissionDashboardController.YTDCommissions('JUL');
            CommissionDashboardController.MonthCommissions('JUL');    
        }
    }
}
Hi!

What's an efficient approach to combine different components in a formula for a checkbox field? I am hoping to create a checkbox field where it will checked when it satisfies a few components: 1. when another checkbox field is checked, 2. when another field within the same object page is "over" a percentage, 3. when another field is "under" a percentage.

How would you combine the IF ( ) and AND ( ) in this scenario? Thank you!!

 
scenario :   Case is created in Salesforce,  Immediatly this case details be moved to third patry systems ( .net system, java sysstem,.......)
how can i do this ?
example : 
case # 12345 created in salesforce, immediatly case reflected in third party systems like java ,.net or some other systems.
Due to project cost, not going for opiton use third party integration tools like Dell boomi......or any other tools.

please provide any ideas on this requirement 
Thanks 
I have a simple apex controller extension and created a basic unit test to verify the returned page reference from the controller is expected value.
When I run the test I get failure with below message - clearing showing the values do match???

System.AssertException: Assertion Failed: Page Reference should be for the Opportunity:
Expected: System.PageReference[/0065B000007l82WQAQ],
Actual: System.PageReference[/0065B000007l82WQAQ]

Here is test code:
     @isTest
     static void testOppContractCreateNotCreated() {   /* opportunity stage is not set to correct value for contract create */
        setupTestData();
        PageReference expectRef = new PageReference('/' + opp.Id);
          Test.startTest();
                stdCont = new ApexPages.Standardcontroller(opp);
            contExt = new OpportunityCreateContractContExt(stdCont);  
             PageReference createContractPageRef = Page.createAdSalesContract;
            Test.setCurrentPage(createContractPageRef);
            PageReference goToRef = contExt.getgoToContract();
            system.debug(opp);
            system.debug(goToRef);            
         Test.stopTest();
        system.assertEquals(expectRef, goToRef,'Page Reference should be for the Opportunity');
     }
Hey!

I'd like to purge all objects not matching certain field values.

Is it possible to create a batch class removing all tasks older than a certain date, except the task with an ID matching an Account field "Task ID"? This would leave 1 task with ID = Account.TaskID.

Thanks for any help!
We have recently setup a couple picklists on an object that are restricted values one is a controlling field for the other!
The object does not support record types (OrderItems) so there is no restriction based on record type.
I would like to setup my test data to query the fields to get valid values so that the tests do not rely on specific values which could be changed by an Admin!

I'm stuck at the point where I can describe the field but not sure how to get the picklist values or the dependencies??
Schema.DescribeFieldResult dfr = Schema.sObjectType.OrderItem.fields.field1__c;
Schema.DescribeFieldResult dfr = Schema.sObjectType.OrderItem.fields.field2__c;

Looking for tips to find a valid value for field1 and based on the value find valid value on field2 which is controlled by field1.

Any pointer to general reference for this would get me pointed in the right direction or if you have it handy code examples are welcome too!

Thanks
Debra
I have a Flow that needs to do a lookup on some custom settings where the SetupOwnerId = OrgId.
However when an end-user runs the flow it produces this error (note as Sys Admin I can run the Flow)

Error element getOrgID (FlowRecordLookup).
This error occurred when the flow tried to look up records: ; nested exception is: common.exception.ApiQueryException: sObject type 'Organization' is not supported.

I also tried a Flow formula field set to be {!$Organization.Id} this produced errors as well.

Other posts seem to indicate that for user to see the Org data they need to have View All Data privs.  This is not possible for our data and since this is not Apex I cannot adjust the sharing. 
I hope not to have to had code the OrgId in a Flow variable as this is very bad practice as it would require Flow edits to move the Flow from Sandbox Orgs to Production.

Any suggestions?
Thanks!
Debra
We have different record types for Orders and depending on the Record Type fields populated for Order Products differ.
Since Salesforce does not support RTs for Order Products (as well as Opp/Quote products) I developed visual force page with conditional formatting based on RT for editting Order Products.

However can't figure out a method to override Edit All button with VisualForce page using Standard or List Controller - trying to avoid writing a custom controller.   When I try to use List controller get error that Order Products object is not supported.

Any suggestions?

Thanks
Debra

Hi

In Syndication Feed Detail: I am creating URL 'Mapping' as below

ft:"Jobs",fa:" ",et:jt__c,el:"https://xyz.secure.force.com/?jobIds="+Id+"+'&'+page=JobDetailPage&jobSite=default&p=Candidate",ec:"Job Title: "+jt__c+"<br>"+"Job Industry:"+ji__c+"<br>"+"Job Category: "+jc__c+"<br>"+"City: "+c__c+"<br>"+"State: "+st__c+"<br>"+"Salary: "+Sa__c+"<br>"+"Overall Experience: "+oe__c+"<br>"+"Job Description Rich: "+AVTRRT__Job_Description__c+"<br>Job Summary:"+AVTRRT__Job_Summary__c+"<br>Job Term:"+t__c,ect: "html"

When executing http://xyz.force.com/services/xml/JobFeed the URL

the link is generating the URL as below


href="https://xyz.secure.force.com/MMS__HMSLayout?page=JobDetailPage&amp;JobSite=default&amp;p=Candidate&amp;jobIds=a0F1600000iLjEq" />

Here instaed of &amp; I need only & .

Please let me know how to escape amp;

 

Thanks & Regards,
Krishna Chaitanya