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

  • Chatter
    Feed
  • 5
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 37
    Questions
  • 72
    Replies
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!!

 
You are not able to create or edit this record aganist this account as you are not part of the account team. You need to be on the account team to make any changes

I'm getting this error in while logging into some one user Please could provide me sol
  • November 17, 2016
  • Like
  • 0
Hello,

I am wondering how to create a custom button "New Contract" on the opportunity level.
Is this possible? I could not find an answer anywhere.

Thank you for your time.
Julia

 
I am new to apex coding but thought I understood most of what I need to do.  I have created a vf page that displays some fields amd updates some fields.  When I execute it, I get the following error: "DML not currently allowed" due to the DML "update" statement.  This has me puzzeled as it works from the Anonymous Window.  I would appreciate any help on this.  Following is the class and VF Page. Thanks.

<apex:page controller="Test2">
    <apex:form >
    <apex:pageblock title="Greetings {!$User.FirstName}">
        <apex:pageBlockTable value="{!Clt}" var="c">
            <apex:column value="{!c.Name}"/>
            <apex:column value="{!c.Gender__c}"/>
            <apex:column value="{!c.Age__c}"/>
             <apex:column value="{!c.SDLM__c}"/>
 
        </apex:pageBlockTable>
    </apex:pageblock>
    </apex:form>                                           
</apex:page>


public with sharing class Test2 {
        Public Test2() {
        }
        Public List <Client__c> clt;
        Integer sdlm=1;
         
        Public List <Client__c> getclt (){
            clt = [select Client__c.Name,Client__c.Age__c,
                   Client__c.Gender__c,Client__c.SDLM__c
            From Client__c
                   Order by Client__c.Name DESC];   
     
            For(Client__c c: clt){
                c.SDLM__c = 1;
            }   
                     
            Update clt;
            return clt;
            }
 }


 
Hello,

I have a process builder which gives error like
An error occurred at element myDecision (FlowDecision).
The flow failed to access the value for myVariable_current.email because it hasn't been set or assigned.
This report lists the elements that the flow interview executed. The report is a beta feature
when i add condition like 
email != null && (Rest of logic) 
it always gives error
 
An error occurred at element myDecision (FlowDecision).
The flow failed to access the value for myVariable_current.email because it hasn't been set or assigned.
This report lists the elements that the flow interview executed. The report is a beta feature

Wen i add 
 
Field =>Email
Operator=> Is null
type=>Boolean
AND (Rest of logic) 
The above code dont give error
but it doesnot work as expected.

What can be the reason ? am i missing something

 
  • November 15, 2016
  • Like
  • 0
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.
  • April 26, 2021
  • Like
  • 0
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.
  • January 29, 2020
  • Like
  • 0
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!
  • June 28, 2018
  • Like
  • 0
I have a flow that has an input value setup as a number.  I am calling the flow from a button and passing in a field value.  The field is setup as a formula field of type number with 2 decimal places.   When I launch the Flow I get this error message:
"The value 20,460,026.4 is being provided for variable inNumber but isn't compatible with the variable's data type (Number)."

Any reason why a numeric formula field would not be recognized by a Flow as a number?

Thanks
Debra
  • May 03, 2018
  • Like
  • 0
I have a Flow that creates several types of records:  Contract, Order and Order Products.
Initially if the Flow encountered any errors on the DML elements it would report the ugly "Unexpected Fault" error screen and no data would be created.
I added screens to handle "Fault" outcomes for the DML elements which worked well however if the fault occurred in later part of the Flow - for example when Order Products are inserted the previously inserted Contract and Order remained.

This is not ideal!  Has anyone found a method to make use the Flow does not create/update any data if there is a DML error that is handled by a fault message?
  • July 27, 2017
  • Like
  • 0
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');
     }
  • July 06, 2017
  • Like
  • 0
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
  • June 22, 2017
  • Like
  • 0
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
  • June 19, 2017
  • Like
  • 0
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
  • June 17, 2017
  • Like
  • 0
We have been struggling with salesforce lack of support for Opporutnity, quote and order product record types arghhh.....
Any suggestions on methods to show users different layouts when add, edit and edit all for a products (Opportunity, quote or order).
I would like to avoid/minimize doing any Apex code (i.e custom controller, controller extension) if possible.
One option I'm considering is Visual Force page using standard controller with page sections shown or hidden based on parent Order record's Record type - not 100% sure this is possible without controller extension!
Wondering if there are any tricks to override standard New, Edit buttons to show a specific page layout without VF?
Also any tips to customize the product selection screen and multiple line edit screens?

Thanks
Debra
  • June 13, 2017
  • Like
  • 0
I am wondering if anyone has noticed different test results when running Apex tests manually via Apex Test area vs. running local tests during change set validation/deployment.

I have one test class with some failing tests when run during change set validation but the test all pass when run manually.

In order to isolate the issue I created a simple change set with just one existing custom field in the change set and when I did deployment validation ran local tests and see that my one Apex class had a subset of tests fail but the same tests pass if I run the Test Class tests manually.  

This test class has not been modified for quite some time originally written by a contractor and I do not see any issues with the test code.

Any tips on how to troubleshoot/fix this type of issue - I'm really stuck as I have some Apex code I want to deploy to production but am unable to do so due to this testclass issue.

Thanks
Debra
 
  • June 06, 2017
  • Like
  • 0
I have a Flow that does order activation and it is working fine in one sandbox but deployed to a 2nd sandbox and getting this error:
FIELD_INTEGRITY_EXCEPTION: Order Start Date can't be later than its contract's end date.

Has anyone seen this error?   I checked and double-checked the Contract and Order and the start/end date values are OK.  The Order start/end dates are within the Contract's start/end dates.

Any tips are much appreciated - I am scheduled to demo this flow today but maybe not :-O
  • March 09, 2017
  • Like
  • 0
I have two sandbox Orgs which are both on Spring '17.   I am trying to deploy a change set that includes updates to two Order object page layouts - added a new related list and a new field.   I have deployed page layout updates before for these layouts without issue.
When I validate the CSet I get this error for the two layouts in the Cset - "In field: excludeButtons, no such standard action:Activate"

I did see some older articles that mention issues with older salesforce releases but didn't see how these older issues matched up with my curent issue.
 
  • February 21, 2017
  • Like
  • 0
I have a flow that collects some user inputs and then is expected to update an Opportunity's stage to Closed Won.
The flow correctly updates all other updated fields on the Opportunity but does not modify the Stage Name.  For the Stage Name value I'm using the Picklist option.

Here is a screen shot of the assignment component:
Flow Opportunity Assignment Screen
 
  • January 31, 2017
  • Like
  • 0
I am trying to implement a Conga Composer solution where user clicks a link on Order object page to generate a Conga Merge document in the background and the output is attached to the related Order record and at the same time the Order status is updated. 
I have seen this working for our Quote object but can't find any code/setup that implements this.
  • January 13, 2017
  • Like
  • 0
I'm trying to write a Flow that will convert a quote to an order.  My flow is mostly working well however I am getting unexpected Flow error
"The flow failed to access the value for QuoteLine.Discount because it hasn't been set or assigned.."
After some testing I found that this error occurs when the Discount field on the quoteLine record is not a whole number for example a value of 10.0 works fine but 10.5 produces this error. 
Has anyone experienced this error under this type of scenario?   If so did you find any workaround?
I'm thinking about moving on to Apex which is too bad because otherwise the Flow works quite well.
  • November 15, 2016
  • Like
  • 0
I have a VF page with controller extension that allows users to add/delete/edit OrderItem records in a grid like layout.
The only DML operations included in the controller are to delete or upsert OrderItem records.  However when the delete operation is called I get the following error:
Apex script unhandled exception by user/organization: 005E0000000kS6z/00DS0000001xNZE Source organization: 00DE0000000c2W5 (null) Visualforce Page: /apex/orderItemEntry
 caused by: System.DmlException: Delete failed. First exception on row 0 with id 802S00000008RygIAE; first error: MIXED_DML_OPERATION, DML operation on setup object is not permitted after you have updated a non-setup object (or vice versa): CustomFieldDefinition, original object: OrderItem: []
--------------------
Also here is an extract from the debug log showing the list passed to delete does contain a valid entry for deletion:
14:23:57.0 (105132099)|USER_DEBUG|[184]|DEBUG|DEBUG  DELETE LIST = (OrderItem:{Id=802S00000008RygIAE})
14:23:57.0 (105148186)|STATEMENT_EXECUTE|[185]
14:23:57.0 (105237697)|DML_BEGIN|[185]|Op:Delete|Type:SObject|Rows:1
14:23:57.0 (105252033)|LIMIT_USAGE|[185]|DML|1|150
14:23:57.0 (105267176)|LIMIT_USAGE|[185]|DML_ROWS|1|10000
14:23:57.0 (105287337)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:8
14:23:57.0 (267282230)|DML_END|[185]
14:23:57.0 (267459888)|EXCEPTION_THROWN|[185]|System.DmlException: Delete failed. First exception on row 0 with id 802S00000008RygIAE; first error: MIXED_DML_OPERATION, DML operation on setup object is not permitted after you have updated a non-setup object (or vice versa): CustomFieldDefinition, original object: OrderItem: []


-----------------------------------
Is there possibly some type of hidden or unexpected setup object DML that could occur with VF page using standard Controller (Order) with controller extension?   There is some code in the controller to retrieve (Select only no DML)  the pricebook for the Order but nothing related to setup objects like User, etc...
  • November 08, 2016
  • Like
  • 0

We have a requirement when creating Orders on a Contract that only one Order is Activated at a time.  Looking to write some code that runs when a user activates an Order any other Order that is activated would be updated to a "De-activated" state/status.   I have tried  prototype this using Process Builder/Flows but it appears that this is not possible even when running the process as System Admin user.  I would prefer not to use Apex although it woudl be an option for us if required.  The only way to de-activate is to use the stamdard button on the Order.
 
  • September 23, 2016
  • Like
  • 0
I have a Flow that is launched from a process builder immediate action.  I have two branches in my flow one is working as expected but the other is not.   I turned on the finest level of debug for WORKFLOW but the debug log is pretty much useless.     I was trying to see if I could use PB/Flows instead of Apex Trigger but so far I favoring going back to a trigger!

Process Builder process is called: Opportunity Product Quantity Pricing
Flow is called: Set Opp Product Price Qty Single

I want to be able to see the values passed from the Process to the Flow and if possible see the values for Flow variables and the status of the steps in the Flow but don't see how this is possible to do???

Here is the log output related to the process/flow:

14:06:12.69 (140667650)|WF_FLOW_ACTION_BEGIN|09Lf00000008Xos
14:06:12.142 (142655726)|USER_INFO|[EXTERNAL]|005E0000000kS6z|debra@prn.com.uat|Pacific Standard Time|GMT-07:00
14:06:12.142 (142681500)|FLOW_CREATE_INTERVIEW_BEGIN|00Df0000003aFW9|300E0000000Gx7D|301f00000001If5
14:06:12.142 (144276650)|FLOW_CREATE_INTERVIEW_END|829126b70a73e978483422ccffa11554b649571-5a63|Opportunity Product Quantity Pricing
14:06:12.147 (147426859)|USER_INFO|[EXTERNAL]|005E0000000kS6z|debra@prn.com.uat|Pacific Standard Time|GMT-07:00
14:06:12.147 (147446128)|FLOW_START_INTERVIEWS_BEGIN|1
14:06:12.147 (148076651)|FLOW_START_INTERVIEW_BEGIN|829126b70a73e978483422ccffa11554b649571-5a63|Opportunity Product Quantity Pricing
14:06:12.147 (177147639)|FLOW_START_INTERVIEW_END|829126b70a73e978483422ccffa11554b649571-5a63|Opportunity Product Quantity Pricing
14:06:12.147 (312771894)|FLOW_CREATE_INTERVIEW_BEGIN|00Df0000003aFW9|300E0000000GwvX|
14:06:12.147 (314544502)|FLOW_CREATE_INTERVIEW_END|829226b70a73e978483422ccffa11554b649571-5a64|Set Opp Product Price Qty Single
14:06:12.147 (316342330)|FLOW_START_INTERVIEWS_BEGIN|1
14:06:12.147 (316367698)|FLOW_START_INTERVIEW_BEGIN|829226b70a73e978483422ccffa11554b649571-5a64|Set Opp Product Price Qty Single
14:06:12.147 (316536587)|FLOW_START_INTERVIEW_END|829226b70a73e978483422ccffa11554b649571-5a64|Set Opp Product Price Qty Single
14:06:12.360 (360869924)|USER_INFO|[EXTERNAL]|005E0000000kS6z|debra@prn.com.uat|Pacific Standard Time|GMT-07:00
14:06:12.360 (360887214)|CODE_UNIT_STARTED|[EXTERNAL]|Validation:OpportunityLineItem:00kf00000065ZEZ
.....VALIDATION RULES LOGGING
14:06:12.360 (362577567)|VALIDATION_PASS
14:06:12.360 (362597399)|CODE_UNIT_FINISHED|Validation:OpportunityLineItem:00kf00000065ZEZ
14:06:12.147 (373737598)|FLOW_START_INTERVIEWS_END|1
14:06:12.147 (374065457)|FLOW_START_INTERVIEWS_END|1
14:06:12.69 (376344599)|WF_FLOW_ACTION_END|09Lf00000008Xos
  • June 13, 2016
  • Like
  • 0
We have two record types for opportunities each has a different pricebook and different fields that are applicable when adding products to the opportunity.  This works OK for users who only create one type of opportunity but for some users who could do either record type/price book they would need to see different field list when they add products from the price book to the opportunity.  However do not see a method (non-code) to show a different mini-page layout to the user depending on the RT of the Opp or some other criteria - looks to be assign one layout per profile.

Thanks for any tips.  Also if you have a code based solution that you recommend please let me know as I pretty sure there is no oob solution for this.
  • January 20, 2016
  • Like
  • 0
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.
  • April 26, 2021
  • Like
  • 0
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.
  • January 29, 2020
  • Like
  • 0
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!
  • June 28, 2018
  • Like
  • 0
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 
  • May 18, 2018
  • Like
  • 1
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');
     }
  • July 06, 2017
  • Like
  • 0
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
  • June 22, 2017
  • Like
  • 0
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
  • June 19, 2017
  • Like
  • 0
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
  • June 17, 2017
  • Like
  • 0

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

 

Hi All,

I am looking for architecture of approval process, this helps me in undertsanding the process instance, process history and process node etc, tables in related to approval process such that my motto in firing and email or an notification when an approaval is peding at certain stage if it is more than certain period.

Regards,
raj