-
ChatterFeed
-
5Best Answers
-
0Likes Received
-
1Likes Given
-
37Questions
-
72Replies
Building a Checkbox with Different Components
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!!
-
- Christina Lam 7
- June 28, 2018
- Like
- 0
- Continue reading or reply
Opportunity Object
I'm getting this error in while logging into some one user Please could provide me sol
-
- KMK91
- November 17, 2016
- Like
- 0
- Continue reading or reply
New Contract Button on Opportunity Level
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
-
- Julia Zocolo
- November 15, 2016
- Like
- 0
- Continue reading or reply
DML error message: "DML not currently allowed"
<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;
}
}
-
- Steven Houghtalen
- November 15, 2016
- Like
- 0
- Continue reading or reply
Error | Process builder | An error occurred at element myDecision (FlowDecision).
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 featurewhen 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
-
- Ab
- November 15, 2016
- Like
- 0
- Continue reading or reply
Show Opportunity products when opportunity is clicked
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.
-
- debra
- April 26, 2021
- Like
- 0
- Continue reading or reply
Open existing Lightning Web Component using Visual Studio Code app?
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.
-
- debra
- January 29, 2020
- Like
- 0
- Continue reading or reply
SOQL Query to connect data from emailServicesFunction and ApexClass objects
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!
-
- debra
- June 28, 2018
- Like
- 0
- Continue reading or reply
Flow error - The Value isn't compatible with the variable's data type.
"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
-
- debra
- May 03, 2018
- Like
- 0
- Continue reading or reply
Flow with Fault handling does not rollback all DMLs?
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?
-
- debra
- July 27, 2017
- Like
- 0
- Continue reading or reply
Apex test method with AssertEquals fails when values are equal?
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');
}
-
- debra
- July 06, 2017
- Like
- 0
- Continue reading or reply
Apex test data setup with valid restricted picklist values and controlling field
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
-
- debra
- June 22, 2017
- Like
- 0
- Continue reading or reply
Flow error - sObject type 'Organization' is not supported.
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
-
- debra
- June 19, 2017
- Like
- 0
- Continue reading or reply
Override Edit All Order Products page w Visual Force using Standard Controllers possible?
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
-
- debra
- June 17, 2017
- Like
- 0
- Continue reading or reply
Any tips/tricks/best practice to shown specific page layout for Order Product add/edit/edit all based on Order Record Type
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
-
- debra
- June 13, 2017
- Like
- 0
- Continue reading or reply
Apex tests produce different results change set vs manual execution?
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
-
- debra
- June 06, 2017
- Like
- 0
- Continue reading or reply
Error when trying to activate an Order - "Order Start Date can't be later than its contract's end date"
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
-
- debra
- March 09, 2017
- Like
- 0
- Continue reading or reply
Getting error on Order page layout deployment "In field: excludeButtons, no such standard action:Activate"
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.
-
- debra
- February 21, 2017
- Like
- 0
- Continue reading or reply
Flow Not assigning/updating Opportunity StageName
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:
-
- debra
- January 31, 2017
- Like
- 0
- Continue reading or reply
Conga Composer when background document created automatically update the related record's status
I have seen this working for our Quote object but can't find any code/setup that implements this.
-
- debra
- January 13, 2017
- Like
- 0
- Continue reading or reply
The flow failed to access the value for QuoteLine.Discount because it hasn't been set or assigned is reported when discount is not a whole number???
"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.
-
- debra
- November 15, 2016
- Like
- 0
- Continue reading or reply
MIXED_DML_OPERATION error on delete orderitem records not doing any setup DML???
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...
-
- debra
- November 08, 2016
- Like
- 0
- Continue reading or reply
Methods to de-activate an activated Order using automation/code
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.
-
- debra
- September 23, 2016
- Like
- 0
- Continue reading or reply
Methods to debug auto-launched Flow
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
-
- debra
- June 13, 2016
- Like
- 0
- Continue reading or reply
Any tips/tricks to Customize fields on mini page layout when adding new Opportunity products
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.
-
- debra
- January 20, 2016
- Like
- 0
- Continue reading or reply
Show Opportunity products when opportunity is clicked
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.
- debra
- April 26, 2021
- Like
- 0
- Continue reading or reply
bad value for restricted picklist field: F2F while sending email
In sandbox Enhanced email is enabled.
Did someone faced the same issue and found the solution (what need to be done to resolve this).
- Abhinav Sharma.
- January 29, 2020
- Like
- 0
- Continue reading or reply
Open existing Lightning Web Component using Visual Studio Code app?
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.
- debra
- January 29, 2020
- Like
- 0
- Continue reading or reply
FIELD_INTEGRITY_EXCEPTION: Account ID: id value of incorrect type
Not sure how to diagnose this one.
- Eddie Deveau
- September 09, 2019
- Like
- 0
- Continue reading or reply
How to allow customers tracked in a custom object to access communities?
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...
- Gert Wieland
- September 09, 2019
- Like
- 0
- Continue reading or reply
- ram t 11
- September 09, 2019
- Like
- 0
- Continue reading or reply
How can I populate required fields to creata test for SObjects ?
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
- Mel Lisau
- September 09, 2019
- Like
- 2
- Continue reading or reply
help with query: Too Many SOQL Queries: 101
- //Map of new opp values
- Map<Id, Decimal> mapOfOppIds = new Map<Id, Decimal>();
- Map<Id, Decimal> mapOfUpdatedOppIds = new Map<Id, Decimal>();
- for(Opportunity newOpp : newUpdatedOpp) {
- if(mapOfOldOppArr.get(newOpp.Id) != mapOfUpdatedArr.get(newOpp.Id)
- && newOpp.Renewed_Opportunity__c == true){
- mapOfOppIds.put(newOpp.Originating_Opp_Id__c, newOpp.ARR__c);
- mapOfUpdatedOppIds.put(newOpp.Id, newOpp.ARR__c);
- }
- }
- system.debug('values in mapOfOppIds ' +mapOfOppIds);
- system.debug('values in mapOfUpdatedOppIds ' +mapOfUpdatedOppIds);
- //Query Original Opp Line Items
- List<OpportunityLineItem> oli = [Select Id, OpportunityId, UnitPrice, Originating_OLI_Id__c FROM OpportunityLineItem
- WHERE OpportunityId IN :mapOfOppIds.keySet()];
- System.debug('Opp Line Items from original opp ' +oli);
- Dbjensen
- June 28, 2018
- Like
- 0
- Continue reading or reply
SOQL Query to connect data from emailServicesFunction and ApexClass objects
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!
- debra
- June 28, 2018
- Like
- 0
- Continue reading or reply
i need to increase code coverage for test class
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');
}
}
}
- arun rupesh
- June 28, 2018
- Like
- 0
- Continue reading or reply
Building a Checkbox with Different Components
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!!
- Christina Lam 7
- June 28, 2018
- Like
- 0
- Continue reading or reply
Integration Question
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
- VRK
- May 18, 2018
- Like
- 1
- Continue reading or reply
Apex test method with AssertEquals fails when values are equal?
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');
}
- debra
- July 06, 2017
- Like
- 0
- Continue reading or reply
Purge all objects not matching criteria
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!
- Patrick Conner
- July 06, 2017
- Like
- 0
- Continue reading or reply
Apex test data setup with valid restricted picklist values and controlling field
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
- debra
- June 22, 2017
- Like
- 0
- Continue reading or reply
Flow error - sObject type 'Organization' is not supported.
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
- debra
- June 19, 2017
- Like
- 0
- Continue reading or reply
Override Edit All Order Products page w Visual Force using Standard Controllers possible?
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
- debra
- June 17, 2017
- Like
- 0
- Continue reading or reply
Escape & and replace with & in Syndication Feed URL
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&JobSite=default&p=Candidate&jobIds=a0F1600000iLjEq" />
Here instaed of & I need only & .
Please let me know how to escape amp;
Thanks & Regards,
Krishna Chaitanya
- Krishna Chaitanya Hota
- July 16, 2015
- Like
- 0
- Continue reading or reply
Architecture for approaval process
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
- raj kiran
- November 18, 2014
- Like
- 1
- Continue reading or reply