• Alain Cabon
  • ALL STAR
  • 11842 Points
  • Member since 2016

  • Chatter
    Feed
  • 374
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 0
    Questions
  • 2345
    Replies

Hi, i need to create event on lead for a test apex.

The EndDateTime (or activityDate) of this event need to be past.

I have create a lead and event on this lead but i can't choose a negative EndDateTime.
How can i do ?

It's possible to set a date time on Start Test for launch the test in the futur? Ty

I'm using an admin account and using an org setup as "Dev Hub".  

When creating the scratch org:

sfdx force:org:create -f project-scratch-def.json -a AbcScratchOrg

I receive this error message: 

ERROR running force:org:create:  We couldn't create this sandbox or scratch org because the associated Dev Hub isn't authorized. Authorize the Dev Hub and try again.

I've ensured the org is indeed configured as Dev Hub and that the admin user in visual studio code is set:

Sfdx force:config:set defaultdevhubusername=<devhubusername> --global

User-added image

Any ideas/help on what might be the issue would be much appreciated.
 
Hi - I'm relatively new to Lightning so I'm not sure where to look for this.

I have a community page that I've built with Builder, and it has a component on it, and a language switcher.  Guests can view the page, and switch between English and French.

There's one particular component that I need to hide when the user's language is French.

How can I do that?

I looked at Audiences but I don't see how I can create an audience based on a guest user's selected language.

There's <aura:renderif> but I don't see how I can apply that to the page I built with Builder.

The component I'm trying to hide is a Contact Support form, so it's fairly complicated inside otherwise I could do in HTML/JavaScript.

Is there an easy way to do this?

Thanks!
 -- Steve

I have a set of flows from a previous admin, and I'm trying to find how those screen flows are launched.   Is there a way to tell if they are attached to a button, or a visual force page or some other way?   Is it possible to query this via soql so I can get a list of flows and their related launch points?   Hope that makes sense.   

I'll need to move these flows to a new org, but that org won't have the identical schema.  I need to know how the screen flows are launched so I can replicate this action in a new org with a different schema. 

TIA for your help

Why does this RegEx pattern not working in Salesforce ?

pattern myPattern = pattern.compile('@(microsoft|ms|microsoftsurface|msstore).com');
System.debug(myPattern.matcher('aba@ms.com').matches());

I tested it in https://regexr.com/ and it works !
  • December 06, 2019
  • Like
  • 0
Hi! I am working on a project to load account information per criteria in a data table and allow users to select which they want to create a new record for. 

However I am unable to pass the rows selected by the user to the controller. the value is returning as undefined or null. Please help!

Here is my code: 
COMPONENT: 
<aura:component controller = "JMA_SearchforAllChildrenAccounts_Ctr" implements="lightning:availableForFlowActions,force:hasRecordId,lightning:availableForFlowScreens,force:lightningQuickActionWithoutHeader" access="global" >
    <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
    <aura:attribute name="recordId" type="String" access="global"/>
    <aura:attribute name="AccountList" type="Account[]"/>
    <aura:attribute name="childrenAccount" type="Account[]" access="global" />
    <aura:attribute name="data" type="Object" />
    <aura:attribute name="SelectedAccount" type="Account[]" access = "global"/>
    <aura:attribute name="columns" type="List"/>
        <div class="slds-page-header">
        <div class="slds-page-header__row">
                            <div class="slds-page-header__name-title">
                                <h1>
                                    <span class="slds-page-header__title slds-truncate" title="Rohde Corp - 80,000 Widgets">Select Accounts for Deal Proposal</span>
                                </h1>
                            </div>
                        </div>
                        <p class="slds-page-header__name-meta">   Selected Account</p>
                    </div>
    <lightning:datatable 
                         data="{!v.data}" 
                         columns="{!v.columns}" 
                         keyField="id" 
                         selectedRows="{! v.selectedRows }" 
                         maxRowSelection="{! v.maxRowSelection }" 
                         onrowselection="{! c.updateSelectedText }" />
    <br/>
    <center>
        <lightning:button variant="success" label="Create Deal Proposal" title="Create Deal Proposal" onclick="{!c.handleSelect}"/>        
    </center>
</aura:component>

CONTROLLER:

({
    doInit : function(component, event, helper) {
        var recordId = component.get('v.recordId');
        var action = component.get("c.PullChildrenAccounts");
        action.setParams({
            'recordId': recordId,
            'strObjectName' : 'Account',
            'strFieldSetName' : 'JMA_Deal_Proposal_Lightning_Component'
        });
        action.setCallback(this, function(response){
               var state = response.getState();
        if(state === "SUCCESS"){
            component.set("v.data", response.getReturnValue().lstDataTableData);
            component.set("v.columns", response.getReturnValue().lstDataTableColumns);
            }else if (state === 'ERROR'){
                var errors = response.getError();
                if (errors) {
                    if (errors[0] && errors[0].message) {
                        console.log("Error message: " +
                                    errors[0].message);
                    }
                } else {
                    console.log("Unknown error");
                }
            }else{
                console.log('Something went wrong, Please check with your admin');
            }
        });
        $A.enqueueAction(action);
    },
     
    
    updateSelectedText : function(component, event, helper){
        var selectedRows = event.getParam('selectedRows');
        console.log('selectedRows'+selectedRows);
        component.set("v.selectedRowsCount" ,selectedRows.length );
        var rowCount = component.get("v.selectedRowsCount");
        console.log('rowCount'+rowCount);
        let obj =[] ; 
        for (var i = 0; i < selectedRows.length; i++){
            
            obj.push({Name:selectedRows[i].Name});
            
        }
        component.set("v.selectedRowsDetails" ,JSON.stringify(obj) );
        component.set("v.selectedRowsList" ,event.getParam('selectedRows') );
        console.log('obj: '+obj);
    },
    
    handleSelect: function (component, event, helper) {

        var arr = component.get('v.data');
        var obj =  component.get("v.selectedRowsList");
        var rowCount = component.get("v.selectedRowsCount");
        console.log('rowCount'+rowCount);
        console.log('obj '+JSON.stringify(obj) );
        var updateAction = component.get("c.SelectedAccounts");
        updateAction.setParams({ AccountList: obj});
        updateAction.setCallback(this, function(a) {
            $A.get('e.force:refreshView').fire();
        });
        $A.enqueueAction(updateAction);
       
       
    },
    
})
Hi all,

I built a report with report type Opportunities and would like to add a filter saying Close Date <= 31.12.CURRENT YEAR. For this year it would be <= 31.12.2019.

I found in the Salesforce Documentation the following statement:

For example, instead of filtering on Close Date greater than Jan 1, 2017, filter using a relative date: Close Date equals this year.

Attached the link to the documentation:

https://help.salesforce.com/articleView?id=filter_dates_relative.htm&type=5

If I use Close Date <= THIS YEAR I am wondering if this is the correct solution, as THIS YEAR means "Starts at 12:00:00 AM on January 1 of the current year and continues through the end of December 31 of the current year". I just want to tell Salesforce, I want all records with Closed Date <= LAST DAY OF THE CURRENT YEAR without using any formulas.

If using formulas what would be a practical approach here?.
Sorry in advance, the string below is long. I don't know why I got the error message "Error: Incorrect parameter type for function 'OR()'. Expected Boolean, received Text"

OR(
    IF(
       AND(
           OR(
              PE_company__c = FALSE ,
              PE_Portfolio_Company__c = FALSE
              ) ,
           OR(
              CONTAINS(LinkedIn_Company_Size__c ,'Self-employed') ,
              CONTAINS(LinkedIn_Company_Size__c ,'2-10 employees') ,
              CONTAINS(LinkedIn_Company_Size__c ,'N/A') ,
              CONTAINS(LinkedIn_Company_Size__c ,'') 
              )
           ) ,
       
       '0.5' , '0'
       ) ,

    IF(
       OR(
          AND(
              Years_of_work_exp__c  >= 8 ,
              NOT(
                  OR(
                     CONTAINS(LinkedIn_Company_Size__c ,'Self-employed') ,
                     CONTAINS(LinkedIn_Company_Size__c ,'2-10 employees') ,
                     CONTAINS(LinkedIn_Company_Size__c ,'11-50 employees') ,
                     CONTAINS(LinkedIn_Company_Size__c ,'N/A') ,
                     CONTAINS(LinkedIn_Company_Size__c ,'') 
                     )
                  )
              ) ,
          OR(
             CONTAINS( Current_Title__c , 'director') ,
             CONTAINS( Current_Title__c , 'vice president') ,
             CONTAINS( Current_Title__c , 'president') ,
             CONTAINS( Current_Title__c , 'general manager') ,
             CONTAINS( Current_Title__c , 'chief') ,
             CONTAINS( Current_Title__c , 'officer') ,
             CONTAINS( Current_Title__c , 'CEO') ,
             CONTAINS( Current_Title__c , 'COO') ,
             CONTAINS( Current_Title__c , 'CSO') ,
             CONTAINS( Current_Title__c , 'CTO') ,
             CONTAINS( Current_Title__c , 'CFO') ,
             CONTAINS( Current_Title__c , 'CHRO') ,
             CONTAINS( Current_Title__c , 'SVP') ,
             CONTAINS( Current_Title__c , 'EVP') 
             )
          ) ,

       '1', '0'
       ) ,
    
    IF(
       AND(
           OR(
              PE_company__c = TRUE ,
              PE_Portfolio_Company__c = TRUE
              ) ,
           OR(
              Years_of_work_exp__c  >= 8 ,
              CONTAINS( Current_Title__c , 'managing director') ,
              CONTAINS( Current_Title__c , 'principal') ,
              CONTAINS( Current_Title__c , 'vice president') ,
              CONTAINS( Current_Title__c , 'president') ,
              CONTAINS( Current_Title__c , 'vp') ,
              CONTAINS( Current_Title__c , 'operating') ,
              CONTAINS( Current_Title__c , 'partner') ,
              CONTAINS( Current_Title__c , 'executive') ,
              CONTAINS( Current_Title__c , 'chief') ,
              CONTAINS( Current_Title__c , 'general manager') ,
              CONTAINS( Current_Title__c , 'officer') ,
              CONTAINS( Current_Title__c , 'CEO') ,
              CONTAINS( Current_Title__c , 'COO') ,
              CONTAINS( Current_Title__c , 'CSO') ,
              CONTAINS( Current_Title__c , 'CTO') ,
              CONTAINS( Current_Title__c , 'CFO') ,
              CONTAINS( Current_Title__c , 'CHRO') ,
              CONTAINS( Current_Title__c , 'Director') ,
              CONTAINS( Current_Title__c , 'Portfolio operations') ,
              CONTAINS( Current_Title__c , 'Talent') ,
              CONTAINS( Current_Title__c , 'Chief talent officer') ,
              CONTAINS( Current_Title__c , 'Head of HR') ,
              CONTAINS( Current_Title__c , 'SVP') ,
              CONTAINS( Current_Title__c , 'EVP') 
              )
           ) ,

       '2', '0'
       )
   )

Thanks,

Richard
Hi All,

Let me preface this with a disclaimer. I am fairly new to SalesForce development. But I have 11 years experience as a developer.

I am working on a LWC that calls an Apex controller.

The Apex controller runs a fairly simple SOQL query against a custom object Move_Type__c. It has a master detail relationship with another Custom object Move_Goal_Type__c (see below)

Move_Type & Move_Goal_Type

Here is the query: 
[SELECT Name, Id
FROM pursue02__Move_Type__c
WHERE pursue02__Move_Goal_Type__r.Id = :movegoalTypeId ]
The variable comes into the controller (MoveTypeController) as an Id through a method getMoveTypesByMoveGoalTypeId which is decorated with @AuraEnabled(cacheable=true)

When I execute anonynmous, it works as expected, I get a list of Move_Type__c records with the Name and Id.

When the LWC calls it, it returns an empty array. Now I have debugged the method System.debug(movegoalTypeId) and it shows the correct value. And I assigned the SOQL results to a variable and output that as well, it shows values in the debug logs.

I have also checked the network traffic via chrome developer tools and it's sending the value as expected:
message: {
    "actions": [
        {
            "id": "815;a",
            "descriptor": "aura://ApexActionController/ACTION$execute",
            "callingDescriptor": "UNKNOWN",
            "params": {
                "namespace": "pursue02",
                "classname": "MoveTypeController",
                "method": "getMoveTypesByMoveGoalTypeId",
                "params": {
                    "goalTypeId": "a013k00000aWHa6AAG"
                },
                "cacheable": true,
                "isContinuation": false
            }
        }
    ]
}
But as I said it returns an empty array:
"actions": [
        {
            "id": "815;a",
            "state": "SUCCESS",
            "returnValue": {
                "returnValue": [],
                "cacheable": true
            },
            "error": []
        }
    ],
We have checked the permissions on both Move_Type__c and Move_Goal_Type__c, and they all appear to be correct.

Any one know what we are doing wrong? I'm scratching my head on this one.

Any help would be greatly appreciated!

 
Hello all, 

I need some help to understanf the dependency and feasibility of integratng a website to salesforce. Here is my use case that I need help with: 

We have a system (act as a front end) for users to review status of their contacts based on region. each region will show a number of contacts that the user can create a request against all of them for processing based on the region. One request to be submitted, when the request is completed and submitted, we want to send the request to salesforce to create the request and assign the contacts to that request in salesforce (Salesforce was populated with the contacts from the front end system manually). 

Now, we have in Salesforce the contact object and Request object, the request object will capture the request information filled on the front end page. We also have a junction object between contact and Request object called Request members so that we can assign as many contacts to relate to the request record, this object is called Request members. 

Now, what integration method is applicable here that will allow me to first insert a request record, capture the record id, and then use that ID to related the Request members to it and the contacts eventually ? 

I need to be able to present in salesforce that there is one request for these 10 contacts, and type of that request was region. 

Should i use rest api ? How it will work ? please provide the logical sequence for this type of integration. 
 
We are looking to add a field to the Opportunity called Contract Terms. We want this field to look at all products associated with the opportunity and find the earlieast start date and the latest end date?

Any ideas?
I have to delete alerts whne expiration datetime has reached today's datetime
My expiration datetime is showing as 2019-10-05T00:00:00.000Z
I want to delete this record on 5th Oct but I am getting unknown error parsing query when I execute in query editor:
Select Id from Alert_vod__c where Expiration_Date_vod__c <= system.now()

Please help.

 
  • September 28, 2019
  • Like
  • 0
I have a formula field that should be calculating the number of weekdays a case was open. If the case is closed it calculates weekdays between create and closed date; if case is open it calculates age from today and create date. However, I have a closed case that was opened Thursday 8/15/2019 and closed Monday 8/19/2019 and the number that is being returned is zero. Can anyone see my error?
 
If( IsClosed,

(CASE(MOD(Datevalue(CreatedDate) - DATE(1985,6,24),7),
0 , CASE(MOD(ClosedDate - CreatedDate ,7),1,2,2,3,3,4,4,5,5,5,6,5,1),
1 , CASE(MOD(ClosedDate - CreatedDate ,7),1,2,2,3,3,4,4,4,5,4,6,5,1),
2 , CASE(MOD(ClosedDate - CreatedDate ,7),1,2,2,3,3,3,4,3,5,4,6,5,1),
3 , CASE(MOD(ClosedDate - CreatedDate ,7),1,2,2,2,3,2,4,3,5,4,6,5,1),
4 , CASE(MOD(ClosedDate - CreatedDate ,7),1,1,2,1,3,2,4,3,5,4,6,5,1),
5 , CASE(MOD(ClosedDate - CreatedDate ,7),1,0,2,1,3,2,4,3,5,4,6,5,0),
6 , CASE(MOD(ClosedDate - CreatedDate ,7),1,1,2,2,3,3,4,4,5,5,6,5,0),
999)
+ (FLOOR((ClosedDate - CreatedDate)/7)*5)
-
IF(OR(
NOT(MOD( Datevalue(CreatedDate) - DATE (2000 ,1, 1) ,7)=0),
NOT(MOD( Datevalue(CreatedDate) - DATE (2000 ,1, 1) ,7)=1)), 1, 0)),

(CASE(MOD(Datevalue(CreatedDate) - DATE(1985,6,24),7),
0 , CASE(MOD(Today() - Datevalue(CreatedDate) ,7),1,2,2,3,3,4,4,5,5,5,6,5,1),
1 , CASE(MOD(Today() - Datevalue(CreatedDate) ,7),1,2,2,3,3,4,4,4,5,4,6,5,1),
2 , CASE(MOD(Today() - Datevalue(CreatedDate) ,7),1,2,2,3,3,3,4,3,5,4,6,5,1),
3 , CASE(MOD(Today() - Datevalue(CreatedDate) ,7),1,2,2,2,3,2,4,3,5,4,6,5,1),
4 , CASE(MOD(Today() - Datevalue(CreatedDate) ,7),1,1,2,1,3,2,4,3,5,4,6,5,1),
5 , CASE(MOD(Today() - Datevalue(CreatedDate) ,7),1,0,2,1,3,2,4,3,5,4,6,5,0),
6 , CASE(MOD(Today() - Datevalue(CreatedDate) ,7),1,1,2,2,3,3,4,4,5,5,6,5,0),
999)
+ (FLOOR((Today() - Datevalue(CreatedDate))/7)*5)
-
IF(OR(
NOT(MOD( Datevalue(CreatedDate) - DATE (2000 ,1, 1) ,7)=0),
NOT(MOD( Datevalue(CreatedDate) - DATE (2000 ,1, 1) ,7)=1)), 1, 0)))

 
Hello,

I have built an automation tool to help with regression testing, and so far it works without any issues in the Summer 19' release. I had a sandbox reserved to test the automation tool in the Winter 2020 release, and I am unable to locate multi-select picklists and custom forums under related lists in the Winter 2020 preview of Salesforce.

I have used Selenium functions to locate elements, JavaScript, and JQuery, all which work on the Summer 19 release but not the Winter 2020 release.

User-added imageAAs you can see, I am able to locate the same value in the multi-select picklist with no issues..

User-added imageI am unable to locate the elements that I was able to locate in Summer 2019

Does anyone have any idea why this may be happening?
I am just a couple days on with this company. They have the following Apex Class that runs nightly through a batch. We would like the ability to create a Lightning Action/Quick Action to place on the page layout so that this can also be invoked at any time during the day if needed.
 
global class NightlyJobs Implements Schedulable {
    
    global void execute (SchedulableContext sc) {
        
        SendToOrder_Subscriptions runSendToOrder_Subscriptions = new SendToOrder_Subscriptions();
        database.executebatch(runSendToOrder_Subscriptions,100);
        
        ContractRenewalManager runContractRenewalManager = new ContractRenewalManager();
        database.executebatch(runContractRenewalManager,1);
        
    }
    
    
}
This seems to reference the following sets of Apex as well:

ContractRenewalManager
global class ContractRenewalManager implements Database.Batchable<sObject>, Database.Stateful {

    global Integer totalContractsUpdated = 0;

    global Database.QueryLocator start(Database.BatchableContext BC) {

        datetime eligibilityDate = system.now().addMonths(4);
        string eligibilityDateFormatted = eligibilityDate.format('yyyy-MM-dd');

        // Build Contracts Dataset
        string queryContracts = 'SELECT id, SBQQ__RenewalForecast__c FROM Contract WHERE EndDate <= ' + eligibilityDateFormatted + ' AND SBQQ__RenewalForecast__c = false AND Disable_Renewal_Auto_Creation__c = false AND Status = \'Activated\'';
        return Database.getQueryLocator(queryContracts);
    }

    global void execute(Database.BatchableContext BC, List<Contract> scope) {

        // Vars
        List<Contract> listContractsToUpdate = new List<Contract>();
        List<Exception__c> list_newExceptions = new List<Exception__c>();

        // Loop through all Contracts
        for (Contract eachContract: scope) {

            eachContract.SBQQ__RenewalForecast__c = true;
            listContractsToUpdate.add(eachContract);

        }
        // UPDATE - Contract Records
        List<Database.SaveResult> listContractsToUpdate_SaveResults = database.update(listContractsToUpdate, false);

        // RESULTS
        for (Database.SaveResult eachResult: listContractsToUpdate_SaveResults) {
            // ON SUCCESS
            if (eachResult.isSuccess()) {
                System.debug('== DEBUG: Updated Contract Record ==>> ' + eachResult.getId());
                totalContractsUpdated++;
                // ON FAIL
            } else {
                for (Database.Error eachError: eachResult.getErrors()) {
                    Exception__c newException = new Exception__c(Purpose__c = 'Set Renewal Forecast to TRUE', Object__c = 'Contract (Update)', Process__c = 'ContractRenewalManager (Apex Class)', Details__c = eachError.getStatusCode() + ': ' + eachError.getMessage() + '\n' + '\n' + 'Field affected by the error: ' + eachError.getFields() + '\n' + '\n' + 'Note: This error is related to Contract ID: ' + eachResult.getId());
                    list_newExceptions.add(newException);
                }
            }
        }

        insert list_newExceptions;

    }

    global void finish(Database.BatchableContext BC) {

        system.debug('DEBUG ---->>>> Total Contracts Updated: ' + totalContractsUpdated);

    }
}

SendToOrderSubscriptions
global class SendToOrder_Subscriptions implements Database.Batchable<sObject>, Database.Stateful {
    
    global Database.QueryLocator start(Database.BatchableContext BC) {
        string queryAccounts = 'SELECT id FROM Account WHERE id IN (SELECT SBQQ__Account__c FROM SBQQ__Subscription__c WHERE SBQQ__Quantity__c > 0 AND Send_To_Order__c = true AND Added_To_Order__c = false AND Status__c != \'Cancelled\')';
        return Database.getQueryLocator(queryAccounts);
    }
    
    global void execute(Database.BatchableContext BC, List<Account> scope) {
        
        // Prepare data ----
        List<Account> thisScopeAccounts = new List<Account>();
        thisScopeAccounts.addAll(scope);
        id standardPricebookId;         
        
        if (Test.isRunningTest()) {
            standardPricebookId = Test.getStandardPricebookId();
        } else {
            standardPricebookId = [SELECT id FROM Pricebook2 WHERE isStandard = true].id;
        }
        
        List<PricebookEntry> listofPBEs = [SELECT id, Product2id, Pricebook2id FROM PricebookEntry WHERE Pricebook2id = :standardPricebookId];
        Map<id,id> pricebookEntryids = new Map<id,id>();
        List<Exception__c> newExceptions = new List<Exception__c>();
        
        for (PricebookEntry eachPBE : listofPBEs) {
            pricebookEntryids.put(eachPBE.Product2id,eachPBE.id);           
        }
        
        List<SBQQ__Subscription__c> thisScopeSubscriptions = [SELECT id, SBQQ__Account__c, Bill_To_Account__c, Business_Entity__c, Accounting_Quantity__c, 
                                                              SBQQ__Product__c, Display_Name__c, Product_Description__c, SBQQ__SubscriptionStartDate__c, 
                                                              SBQQ__SubscriptionEndDate__c, SBQQ__ListPrice__c, SBQQ__QuoteLine__c, SBQQ__NetPrice__c, 
                                                              Transaction_Number__c, Purchase_Order__c 
                                                              FROM SBQQ__Subscription__c 
                                                              WHERE SBQQ__Quantity__c > 0 AND Send_To_Order__c = true AND Added_To_Order__c = false AND Status__c != 'Cancelled' 
                                                              AND SBQQ__Account__c IN :thisScopeAccounts];
        
        
        List<AggregateResult> aggregatedSubscriptions = [SELECT SBQQ__Account__c, Bill_To_Account__c, Business_Entity__c, Bill_To_Account__r.Billing_Contact__c, MIN(SBQQ__SubscriptionStartDate__c) StartDate, MAX(SBQQ__SubscriptionEndDate__c) EndDate FROM SBQQ__Subscription__c WHERE SBQQ__Account__c IN :thisScopeAccounts AND Send_To_Order__c = true AND Added_To_Order__c = false GROUP BY SBQQ__Account__c, Bill_To_Account__c, Business_Entity__c, Bill_To_Account__r.Billing_Contact__c];
        List<Order> newOrders = new List<Order>();
        
        // Create Orders
        for (AggregateResult eachNewOrder : aggregatedSubscriptions) {
            Order newOrder = new Order(
                Accountid = (id)eachNewOrder.get('SBQQ__Account__c'),
                Bill_To_Account__c = (id)eachNewOrder.get('Bill_To_Account__c'),
                Business_Entity__c = (id)eachNewOrder.get('Business_Entity__c'),
                BillToContactId = (id)eachNewOrder.get('Billing_Contact__c'),
                EffectiveDate = (date)eachNewOrder.get('StartDate'),
                EndDate = (date)eachNewOrder.get('EndDate'),
                Pricebook2id = standardPricebookId,
                Type = 'Subscription Order',
                Status = 'Draft'
            );
            newOrders.add(newOrder);
        }
        
        // INSERT Orders from source record aggregate data
        List<Database.SaveResult> newOrders_SaveResults = database.insert(newOrders, false);
        integer orderInsertIndex = 0;
        
        // RESULTS
        for (Database.SaveResult eachResult : newOrders_SaveResults) {
            // ON SUCCESS
            if (eachResult.isSuccess()) {
                System.debug('== DEBUG: Inserted Order Record ==>> ' + eachResult.getId());
                // ON FAIL
            } else {
                for (Database.Error eachError : eachResult.getErrors()) {
                    Exception__c newException = new Exception__c(Purpose__c = 'Inserting Order records', Object__c = 'Order (Insert)', Process__c = 'SendToOrder_Subscriptions (Apex Class)', Details__c = eachError.getStatusCode() + ': ' + eachError.getMessage() + '\n' + '\n' + 'Field affected by the error: ' + eachError.getFields() + '\n' + '\n' + 'Note: This error is related to Account ID: ' + newOrders[orderInsertIndex].Accountid);
                    newExceptions.add(newException);
                }
            }
            orderInsertIndex++;
        } 
        
        // Create Order Lines
        List<OrderItem> newOrderLines = new List<OrderItem>();
        
        for (Order eachOrder : newOrders) {
            
            for (SBQQ__Subscription__c eachSubscription : thisScopeSubscriptions) {
                
                if (eachOrder.AccountId == eachSubscription.SBQQ__Account__c && 
                    eachOrder.Bill_To_Account__c == eachSubscription.Bill_To_Account__c && 
                    eachOrder.Business_Entity__c == eachSubscription.Business_Entity__c) {
                        
                        OrderItem newOrderLine = new OrderItem(
                            Orderid = eachOrder.id,
                            SBQQ__Subscription__c = eachSubscription.id,
                            Description = eachSubscription.Product_Description__c,
                            Display_Name__c = eachSubscription.Display_Name__c,
                            ServiceDate = eachSubscription.SBQQ__SubscriptionStartDate__c,
                            EndDate = eachSubscription.SBQQ__SubscriptionEndDate__c,
                            Quantity = eachSubscription.Accounting_Quantity__c,
                            SBQQ__QuotedListPrice__c = eachSubscription.SBQQ__ListPrice__c,
                            UnitPrice = eachSubscription.SBQQ__NetPrice__c,
                            PricebookEntryid = pricebookEntryids.get(eachSubscription.SBQQ__Product__c),
                            Transaction_Number__c = eachSubscription.Transaction_Number__c,
                            Purchase_Order__c = eachSubscription.Purchase_Order__c
                        ); 
                        newOrderLines.add(newOrderLine);
                    }
            }
        }
        
        // INSERT OrderItem records from source records
        List<Database.SaveResult> newOrderLines_SaveResults = database.insert(newOrderLines, false);
        integer orderLinesInsertIndex = 0;
        
        // RESULTS
        for (Database.SaveResult eachResult : newOrderLines_SaveResults) {
            // ON SUCCESS
            if (eachResult.isSuccess()) {
                System.debug('== DEBUG: Inserted OrderItem Record ==>> ' + eachResult.getId());
                // ON FAIL
            } else {
                for (Database.Error eachError : eachResult.getErrors()) {
                    Exception__c newException = new Exception__c(Purpose__c = 'Inserting OrderItem records', Object__c = 'OrderItem (Insert)', Process__c = 'SendToOrder_Subscriptions (Apex Class)', Details__c = eachError.getStatusCode() + ': ' + eachError.getMessage() + '\n' + '\n' + 'Field affected by the error: ' + eachError.getFields() + '\n' + '\n' + 'Note: This error is related to Subscription ID: ' + newOrderLines[orderLinesInsertIndex].SBQQ__Subscription__c);
                    newExceptions.add(newException);
                }
            }
            orderLinesInsertIndex++;
        } 

        database.insert(newExceptions,false);

    }
    
    global void finish(Database.BatchableContext BC) {
        
        // Chain to SendToOrder_Assets Apex Class
        if (!Test.isRunningTest()) {
            SendToOrder_Assets runSendToOrder_Assets = new SendToOrder_Assets();
            database.executebatch(runSendToOrder_Assets,100);
        }
        
    }
}

How would we get started in creating a Lightning Action/Quick Action? Is this possible?
Hello,

I have below error, what can be reason:

Non static method cannot be referenced from a static context: void ContractTriggerHandler.OnAfterUpdate(List<Contract>, List<Contract>, Map<Id,Contract>, Map<Id,Contract>)

Any suggestions ?
I'm trying to figure out how to add X amount of days to a date through the lightning component controller. Here is what I have been trying:

.cmp - 
<aura:component implements="flexipage:availableForAllPageTypes">
        <aura:attribute name="dataInValue" type="Date" />
        <aura:attribute name="dataEndValue" type="Date"/>

        <lightning:input aura:id="startDate" type="date" label="Enter Date" value="{!v.dataInValue}" onchange="{!c.validDate}"/>
        <br/>
        <lightning:input aura:id="endDate" type="date" label="Day they get benefits:" value="{!v.dataEndValue}"/>
        
</aura:component>
.js - 
({
    validDate : function(component,event,helper){
               var data_in = component.get("v.dataInValue");
               var data_out = formatDate(data_in) + 30;
               component.set("v.dataEndValue", data_out);
    }
})
I aa trying to use process builder to create an event at 9:15 on the same date as another event. my formula is

DATETIMEVALUE(TEXT(YEAR([Event].StartDateTime ))+"-"+TEXT(MONTH([Event].StartDateTime ))+"-"+TEXT(DAY([Event].StartDateTime ))+" 09:15:00")

but I get a syntax error.

Can anyone assist with debugging please?

 
Hello
I wrote a lightning/aura component. This component lists all the orders associated with a case. When I running a SOQL query, I am getting 5 unique orders for a particular case, for example. But when I am looking at the lightning component, its displaying the same order 5 times. So I am thinking that the aura component is not iterating the apex list properly. I have the code below. Can anyone pinpoint, where I might have gone wrong?

Apex controller:
public class CC_OrderListController {
    
    @AuraEnabled
    public static List <Order> getOrders(Id caseId) {
        Case c = [select ContactId from Case where Id = :caseId LIMIT 1];
        Id con = c.ContactId;
        system.debug(con);
        
        List<Order> result = [SELECT Id, BillToContact.Email, EffectiveDate, Sub_Total__c, External_Order_URL__c FROM Order where BillToContactId = :con ORDER BY createdDate DESC LIMIT 20];
        system.debug(result);
        return (result == null ? new List<Order>() : result);
    }
    
}

Aura component:
<aura:component implements="flexipage:availableForAllPageTypes,force:hasRecordId" controller="CC_OrderListController" access="global">
    
    <aura:attribute name="data" type="Object"/>
    <aura:attribute name="columns" type="List"/>

    <aura:handler name="init" value="{! this }" action="{! c.init }"/>


    <div style="min-height: 200px;">
        <lightning:datatable
                keyField="id"
                data="{! v.data }"
                columns="{! v.columns }"
                hideCheckboxColumn="true"/>
    </div>
    
</aura:component>

Aura JS controller:
({
    init : function(component, event, helper) {
        
        component.set('v.columns', [
            {label: 'Email', fieldName: 'Email', type: 'text'},
            {label: 'Order Date', fieldName: 'EffectiveDate', type: 'Date'},
            {label: 'Sub Total', fieldName: 'Sub_Total__c', type: 'currency'},
            {label: 'Order Link', fieldName: 'orderLink', type: 'url'}
        ]);

        var fetchData = {
            Email: "",
            EffectiveDate : "",
            Sub_Total__c : "",
            orderLink: ""
        };


        helper.fetchData(component,fetchData);
        
    }
})

JS Helper method:
({
    fetchData : function(component, fetchData) {
        var action = component.get('c.getOrders');
        action.setParams({ "caseId" : component.get('v.recordId') });
        
        var self = this;
        var results = [];
        action.setCallback(this, function(actionResult) {
            var res = actionResult.getReturnValue();
            for(var i = 0; i < res.length;i++){
                fetchData.Email = res[i].BillToContact.Email;
                fetchData.EffectiveDate = res[i].EffectiveDate;
                fetchData.Sub_Total__c = res[i].Sub_Total__c;
                fetchData.orderLink = res[i].External_Order_URL__c;
                
                results.push(fetchData);
            }
            
            component.set('v.data', results)
        });
        $A.enqueueAction(action);
    }
})

Should I use aura iteration tag ? Any help would be greatly appreciated. Thank you
Hi dev team,

I have created a custom object with questions and corresponding marks detailed in several text and number fields to be displayed in a specific graph. The request is to create a Spider Chart.
Is there a existing Ligtning component for this sort of chart?
Or do you advise anything else?

Thank you.
Best Regards,
Ludivine

Hi,
 

This is a question which I really can't find an answer to. In a trigger before insert or update, I like to compare 4 field values from the object named Calculation__c with 4 field values of Driver_Course__c.

The fields on Calculation__c are named: 

  • Course__c
  • Cup__c
  • Tour__c
  • Driver__c
Those 4 fields i like to compare with the following fields of the object Driver_Course__c:
  • Course__c
  • Course__r.Cup__c
  • Course__r.Cup__r.Tour__c
  • Driver__c
With nested for loops it's easy, but I don't want to run into any governor limits, which I will regarding my test class, which gives me the error: CPU Limits exceeds.

I know how to get the data prepared for matching, but the matching itself I really dont know what to do. After removing and adding stuff this is what i got:
 
public without sharing class AutoFillCalculations {
    public static void FillOut(List<Calculation__c> calcList) {

        // Id nodig van Course
        Set<Id> courseIdSet = new Set<Id>();
        // Id nodig van Cup
        Set<Id> cupIdSet = new Set<Id>();
        //Id nodig van Tour
        Set<Id> tourIdSet = new Set<Id>();
        // Id nodig van Driver
        Set<Id> driverIdSet = new Set<Id>();
        Map<Id, Driver_Course__c> driverCourseById = new Map<Id, Driver_Course__c>();


        // Add the Ids to the sets
        for(Calculation__c calc : calcList){
            courseIdSet.add(calc.Course__c);
            cupIdSet.add(calc.Cup__c);
            tourIdSet.add(calc.Tour__c);
            driverIdSet.add(calc.Driver__c);
        }

        // Query  ids met junction object Driver Course

        for(Driver_Course__c driverCourse : [SELECT Id, Driver__c, Course__c, Course__r.Cup__c, Course__r.Cup__r.Tour__c 
                                               FROM Driver_Course__c 
                                              WHERE Course__c IN :courseIdSet
                                                AND Course__r.Cup__c IN :cupIdSet
                                                AND Course__r.Cup__r.Tour__c IN :tourIdSet
                                                AND Driver__c IN :driverIdSet]){
            driverCourseIdByTourId.put(driverCourse.Id, driverCourse); // is this smart?

        }
        
        for(Calculation__c calc : calcList){

            //??????

        }

        


    }
}


Any help would be much appreciated. 
 

Thanks

Hi Can any one help me,
I have a text field in which i am trying to save alpha numeric and i am trying to limit the range between 0100 to 0555 so the values should save between the range and alpha numeric.i worte a formula like this.                 
  AND(
NOT(REGEX(Text__c,"^[a-zA-Z0-9_]*$")),
OR(
VALUE(Text__c) < 0100,
VALUE(Text__c) > 0555 ) )

So here example am giving AC15 value in the field it is working.
if i give the value 0101 it is saving and if i give it as 1111 it is 
also saving which is not correct.REGEX part is working but not the other part  OR Part.
  • March 26, 2020
  • Like
  • 0
Hello, 

I want to show my Scheduled Revenue by account, I have 3 objects with these variables :

- Account : account_name , account_id
- Opportunity : account_id , stage , opportunity_id
- ORSchedule_c : opportunity_id , expected_revenue , date

my goal is to return : account_name , stage , exêcted_revenue , date

Can someone help me with these ?

Thank you ! 

José

Hi, i need to create event on lead for a test apex.

The EndDateTime (or activityDate) of this event need to be past.

I have create a lead and event on this lead but i can't choose a negative EndDateTime.
How can i do ?

It's possible to set a date time on Start Test for launch the test in the futur? Ty

Hi all, 

I am creating a Visual Force page (added to layout) to show a pop-up with the CPQ Quote object loads but it's not actually doing anything. I only dabble in development so any advice is appreciated! Thank you! Here is the VF.

<apex:page StandardController="SBQQ__Quote__c">
<script> window.document.onload = new function(e)
{ if(!SBQQ__Quote__c.SBQQ__ExpirationDate__c < TODAY())
{ alert("Expiry Date is in the Past"); }
}
</script>
</apex:page>

As I cannot capture the "Submit or Approval" click without creating a custom button (as far as I can tell) and already have a Validation rule for when they edit the page this was a solution for any Quotes they do NOT edit before hitting "Submit for Approval".
Hi I am not able to understand why I am not able to get the data from my wire service when I am puting the data in my serach field, when the search field is blank it do render and i can see the data , but when i put any data to search it doesnt react to that search key 

below is the code 
HTML 
<template>
    <lightning-card title="Product Search">
        <div class="slds-m-around_medium">
            <lightning-input name="enter-search" label="Search" type="search" onchange={handleSearch} is-loading={isSearching}></lightning-input><br/>
            <lightning-input name="NABTick" label="NAB Price List" type="checkbox" onchange={handleCheckbox} ></lightning-input><br/>
        <lightning-button label="Search" name="search" title="Search Products" onclick={findProductKey} variant="brand" ></lightning-button>&nbsp;&nbsp;&nbsp;
            <lightning-button label="Cancel" name="cancel" title="Cancel" onclick={handleCancle} ></lightning-button>
        
        </div>
        <div>
            This is the search key value ={searchKey}
            This is NAB Check list Value={NABcheckbox}
        </div>
        
        <template if:true={allProduct.data}>
            <div>
                <template for:each={allProduct.data} for:item=product>
                    This is the prodcut Id :{product.Id}
                  <c-product-search-result-wired key={product.Id} product={product}></c-product-search-result-wired>
                </template>
            </div>
        </template>
    </lightning-card>
    
</template>
Vchild component 
<template>
    <div class="slds-p-around_medium lgc-bg" key={product.Id}>
        <ul class="slds-has-dividers_bottom-space">
            <li class="slds-item">
                <lightning-tile label={product.Name}>
                    <ul class="slds-list_horizontal slds-has-dividers_right">
                        <li class="slds-item">Product Code: {product.ProductCode}</li>
                        <li class="slds-item">Eng Status: {product.Eng_Status__c}</li>
                        <li class="slds-item">Dark Knight</li>
                        <li class="slds-item">Dark Knight</li>
                    </ul>
                </lightning-tile>
            </li>
        </ul>
        </div>     
</template>

Parent JS
import { LightningElement,track,wire } from 'lwc';
import getProducts from '@salesforce/apex/productSearch.getProducts';

const DELAY = 300;
export default class ProductSearchWired extends LightningElement {
    @track searchKey='';
    @track NABcheckbox= false;
    @track allProduct=[];
    
    
    @wire(getProducts,{productSearchKey:'$searchKey'})
    products({data,error}){
        if(data){
            this.allProduct = data;
        }
    }

    handleSearch(event){
        window.clearTimeout(this.delayTimeout);
        const searchKey = event.target.value;
        // eslint-disable-next-line @lwc/lwc/no-async-operation
        this.delayTimeout = setTimeout(() => {
            this.searchKey = searchKey;
        }, DELAY);
    }

    handleCheckbox(){
        this.NABcheckbox = true;
    }

    get isSearching(){
        if(this.allProduct){
            return false;
        } else {
            return true;
        }
    }
}

Child JS File
import { LightningElement,api } from 'lwc';
import { NavigationMixin } from 'lightning/navigation';

export default class ProductSearchResultWired extends NavigationMixin(LightningElement) {
    @api product;

    navigateToProduct(){
        this[NavigationMixin.Navigate]({
            type: 'standard__recordPage',
            attributes: {
                actionName: "view",
                recordId: this.product.Id,
                objectApiName: "Product2"
            }
        });

    }
}

Apex Class Controller
public static List<Product2> getProducts(String productSeachKey)
    {
          if( String.isNotEmpty(productSeachKey))
        {
            return [SELECT Id,Name,ProductCode,Eng_Status__c,Quotable__c,USD_Price__c FROM Product2 WHERE IsActive= true AND Eng_Status__c IN ('Production','Procurement','Prototype','Hold')
                    AND Field_Replaceable_Part__c = false AND Base_Price_List_Item__c != null AND (Name LIKE : '%'+productSeachKey+'%' OR ProductCode LIKE: '%'+productSeachKey+'%')
                    ORDER BY SBQQ__SortOrder__c ASC NULLS LAST];
        } else 
        { 
          return [SELECT Id,Name,ProductCode,Eng_Status__c,Quotable__c,USD_Price__c FROM Product2 WHERE IsActive= true AND Eng_Status__c IN ('Production','Procurement','Prototype','Hold')
          AND Field_Replaceable_Part__c = false AND Base_Price_List_Item__c != null ORDER BY SBQQ__SortOrder__c ASC NULLS LAST];
        }

    }
    
}

When SearchKey is blank the component renders and show all the products
Hi Guys,   I hope you can help me, I only want to know what is the diference beween invoking a remoted method using this  statment 

RemoteClass.remoteActionMethod(str,function(result, event){ if (event.status) { alert(result); } } );

versus this one 

 Visualforce.remoting.Manager.invokeAction(
            '{!$RemoteAction.RemoteClass.remoteActionMethod}',  ...... 

 
I'm using an admin account and using an org setup as "Dev Hub".  

When creating the scratch org:

sfdx force:org:create -f project-scratch-def.json -a AbcScratchOrg

I receive this error message: 

ERROR running force:org:create:  We couldn't create this sandbox or scratch org because the associated Dev Hub isn't authorized. Authorize the Dev Hub and try again.

I've ensured the org is indeed configured as Dev Hub and that the admin user in visual studio code is set:

Sfdx force:config:set defaultdevhubusername=<devhubusername> --global

User-added image

Any ideas/help on what might be the issue would be much appreciated.
 
Hi - I'm relatively new to Lightning so I'm not sure where to look for this.

I have a community page that I've built with Builder, and it has a component on it, and a language switcher.  Guests can view the page, and switch between English and French.

There's one particular component that I need to hide when the user's language is French.

How can I do that?

I looked at Audiences but I don't see how I can create an audience based on a guest user's selected language.

There's <aura:renderif> but I don't see how I can apply that to the page I built with Builder.

The component I'm trying to hide is a Contact Support form, so it's fairly complicated inside otherwise I could do in HTML/JavaScript.

Is there an easy way to do this?

Thanks!
 -- Steve
Hi guys thanks for taking interest in my question
Can you please help me in my code I want to sort my apex:pageBlockTable   columns after clicking on that particular column 

here are my APEX and VF code  which is  sorting  only one column but what I want, when I click on a particular  column header that column will sort again I click on same column header it should reverse
<apex:page standardController="Account" extensions="SAJCustomerContactExt">
<apex:slds />
<style>
.fewerMore { display: none;}
</style>
<apex:pageblock id="CustomList" rendered="{!contacts.size != 0}"> <!---->
<apex:pageBlockTable value="{!contacts}" var="c">
<apex:column headerValue="Contact Name">
<apex:outputLink value="/{!c.id}" id="contactLink" target="_parent">
{!c.Name}
</apex:outputLink>
</apex:column>
<apex:column value="{!c.FirstName}"/>
<apex:column value="{!c.Department}"/>
<apex:column value="{!c.Email}"/>
<apex:column value="{!c.LastName}"/>
<apex:column value="{!c.Phone}"/>
<apex:column value="{!c.Title}"/>
</apex:pageBlockTable>
</apex:pageblock>
</apex:page>

//SAJCustomerContactExt
public class SAJCustomerContactExt {
    private List<Contact> contacts;
    private Account acct;
    public SAJCustomerContactExt(ApexPages.StandardController stdcontroller) {
        this.acct = (Account)stdcontroller.getRecord();
    }
    public List<Contact> getContacts() {
        contacts =[SELECT Id, Name,FirstName, Department,Email, LastName,Title,  Phone  
                   FROM Contact where AccountId =: acct.ID ORDER BY Name LIMIT 900];
        System.debug('DATA SUCCSESSFULLY QUERIED....! '+contacts);
        return contacts;
    }
    
}

 
I am working with compex commision formulas.

I have 95 percent worked out, but have a final challenge

I think I need a custom field,  a checkbox, which answers a simple question

Is the "Billing Date" field value OLDER than the first of last month.

Will start as no, and will change to yes, Would be easy if all months had equal days but they do not :(

I am open to other suggestions but any of them will need some formula to anser this question

Thanks in advance!!

I have a set of flows from a previous admin, and I'm trying to find how those screen flows are launched.   Is there a way to tell if they are attached to a button, or a visual force page or some other way?   Is it possible to query this via soql so I can get a list of flows and their related launch points?   Hope that makes sense.   

I'll need to move these flows to a new org, but that org won't have the identical schema.  I need to know how the screen flows are launched so I can replicate this action in a new org with a different schema. 

TIA for your help

I want to put this out to the sfdc developer community to see if anyone has some feedback on a question I've received as part of a technical assessment for a Salesforce developer role. 

Specifically, a hiring manager has asked me the following:
 
Given the following 2 classes:
Class Folder
name: string
parent: Folder
 
Class File
name: string
parent: Folder
 
Complete the following function in pseudocode to return the full string path of a file.
 
function getFullFilePath(file: File): string {
         …
return path
}
My question is can someone please explain to me how you would respond to this? Also, what is your interpretation of what is being asked?

 
  • January 25, 2020
  • Like
  • 0
I know others have complained about this issue and I haven't found a solution anywhere.  I have a quick action that launches a VF page.  The page makes a minor change to the record and saves.  The pop-up with the VF page closes.  The data on the Lightning Page from which the QUick Action as launched does not have it's data refreshed. Further I found I had to reload the page three or four times before the change that was saved to the database finally appears on the page.  It seems it should be a trivial thing and very useful to make a change with VF.  Yes, lightning programming is wizz-bang cool but for quick and simple stuff when you don't have a lot of time or only have junior programmers available, VF is simpler and faster.


Below is an example.  It does update the record.  But when the action closes it takes several seconds and several reloads for the record in the Detail section of the Lightning page to reflect what has been in the database for several seconds.
public Account myAccount {get; private set;}
    ApexPages.StandardController  std;

    public KKAccountExperController() {
    }

    public KKAccountExperController(ApexPages.StandardController std) {
         Id accountId  = std.getId();
         myAccount = [ select Id, Industry from Account where Id =: accountId ];
         this.std = std;
    }


    public PageReference save() {
        update myAccount;
        PageReference ref = std.view();
        ref.setRedirect(true);
        return ref;
    }

    
}
 
<apex:page standardController="Account" extensions="KKAccountExperController" showQuickActionVfHeader="false">

    <apex:form>
        
        <apex:pageBlock>
            <apex:pageBlockButtons>
                <apex:commandButton value="Save" title="Save" action="{!save}"/>
            </apex:pageBlockButtons>

            <apex:inputField value="{!myAccount.Industry}"/>


        </apex:pageBlock>
                
    </apex:form>


</apex:page>



 
Hi guys,
We just created a library named R.apex, which helps simplify the common tasks in apex code development by adopting a functional style.
It offers tons of utility functions to work with lists, sets, maps and sobjects, making apex code clean and readable. We were suffering from the pain points of writing similar Apex code to complete trivial tasks once and once again, and that is the reason why we want to stop that and start to write reusable code. Here are some examples of what R.apex can do:
 
// Reverse a list
List<Integer> reversedList = R.of(new List<Integer>{ 1, 2, 3 })
    .reverse()
    .toIntegerList();
 
// Fina specific account
List<Account> accountList = ...;
Account acc = (Account)R.of(accountList)
    .find(R.whereEq.apply(new Map<String, Object>{
        'LastName' => 'Wilson',
        'IsDeleted' => false
    }))
    .toSObject();

Hopefully R.apex can help make your Apex code development easier, and you are always welcome to give feedback so that we can improve it.

R.apex is an open source project hosted at https://github.com/Click-to-Cloud/R.apex/.
You can check it out. Feel free to clone it, make changes or submit a PR.

^_^

When someone takes the time/effort to repspond to your question, you should take the time/effort to either mark the question as "Solved", or post a Follow-Up with addtional information.  

 

That way people with a similar question can find the Solution without having to re-post the same question again and again. And the people who reply to your post know that the issue has been resolved and they can stop working on it.