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

  • Chatter
    Feed
  • 367
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 0
    Questions
  • 2306
    Replies
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?.
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. 
 
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?
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
Hello friends, 

Please help me with a simple query to get records if data A is > date B. I tried this soql query in query builder but it give error. 

Select Forecast_Handover__c,Name,Site__c,Forecast_Sales_Date__c from Cbd_plot__c where  Forecast_Handover__c > Forecast_Sales_Date__c

both these forecast date fields are date fields in salesforce I am getting error 'Unknown error parsing query'

but at the same time is I try 

Select Forecast_Handover__c,Name,Site__c,Forecast_Sales_Date__c from Cbd_plot__c where  Forecast_Handover__c > TODAY

its returning me records. 

Many thanks in advance
Hi,
my challenge when doing the above mentioned module fails with the following error:

"The test method doesn’t insert an opportunity with the correct fields. Double check the Name, StageName, and CloseDate and try again."

The requirement is as follows:
In the test method, create an opportunity with the following fields.
Name: 'Sell 100 Widgets'
StageName: 'Prospecting'
CloseDate: Date.today().addMonths(3)


And the code is this:
    Opportunity opp =  new Opportunity(Name='Sell 100 Widgets',
           CloseDate=System.Date.today().addMonths(3),
           StageName='Prospecting');
    insert opp;


Any idea what could be wrong?

 
Hi all,
I have just started in a new company with an old very customize Salesforce instance. I have just discovered that an object has 25.000 new records created each week.
My question is how can I find which process / workflow / trigger or Apex is created these records? 
Thank you for your help.
Sylvie
 
I am working on validation for IPV4 and IPV6 to validate their input.
This IP input fields should also accept the subnet mask.

Valid input in IPV4 field can be :
172.16.0.0
172.16.0.0/8
172.16.0.0/192
213.248.89.98/31

Valid input in IPV6 field can be :
2001:db8:abcd:0012::0/64
2001:db8:abcd:0012:0000:0000:0000:0000
2001:2000:3080:001D::2/126

Is it something possible with regex or custom code? I tried couple of regex solutions but its not working. 
I am new to Sales force API integration with .NET and came accross this issue - can't seem to get the sObject id from QueryResult - the id is null, even though a valid record is returned, and I can see the Name field. Any suggestions?
See my query below:

  string queryStr = $"SELECT id, Name FROM Account Where Name = '{name}'";
                QueryResult qResult = _service.query(queryStr);
                bool done = false;

                if (qResult.size > 0)
                {
                    while(!done)
                    {
                        sObject[] records = qResult.records;

                        for(int i = 0; i < records.Length; i ++)
                        {
                            accountId = records[i].id; // record id is null here
                        }

                        if (qResult.done)
                        {
                            done = true;
                        }
                        else
                        {
                            qResult =
_service.queryMore(qResult.queryLocator);
                        }
                    }            
                }
I have a method called getAccountIds, that is successfully returning a set of Account Ids. I second method that is countContacts(List<Id>acctIds). But when I return the acctIds, it doesn't get added picked up by the second method.
I'm calling the class from an execute anonymous window like this --> 
AccountProcessor.getAccountIds(); 
AccountProcessor.countContacts();



Actual Class and methods. 
 
public class AccountProcessor {
    
    public static List<Id> getAccountIds(){
        List<Id> acctIds = new List<Id>(); 
        For(Account a:[SELECT Id FROM Account LIMIT 200] ){
            acctIds.add(a.Id);
        }
        System.debug('The list of Ids = ' + acctIds); 
        System.debug('The size of List = ' +acctIds.size());
        return acctIds; 
        
    }
   
    
    @future
  
    
    public static void  countContacts(List<Id> acctIds){
       	//Declare Variables.
       	Account accountToUpdate; 
        List<Account> accountsToUpdate = new List<Account>(); 
       	Integer totalContacts = 0; 
        System.debug('Size of List =' + acctIds.size());
        List<Contact> cons = [SELECT Id, AccountId FROM Contact WHERE AccountId IN: acctIds]; 
        System.Debug('Contact List = ' + cons.size()); 
		
        //Loop through the contacts and sum the account Id for each contact. 
        for( Id a : acctIds){
            
            System.Debug('Account Ids on Contact = ' + a); 
          	Contact[] contactIdArray = new List<Contact>();  
                   for(Contact c : cons){
                      // System.debug('Enter Contact Loop ');
                      // System.Debug('Account Id = ' + a);
                       Boolean resultType = a.equals(c.AccountId);
                       //System.Debug('ResultType is ? ' + resultType); 
                        
                      	If(a==c.AccountId){
                             contactIdArray.add(c);
                          	
                       		}
                       
					
	        }
             
             
             accountToUpdate = [SELECT Id FROM Account WHERE Id =: a LIMIT 1]; 
             totalContacts = contactIdArray.size();
             accountToUpdate.Number_of_Contacts__c = totalContacts; 
             accountsToUpdate.add(accountToUpdate); 
             System.debug('Total Contacts = ' + totalContacts);
             System.debug('Total Update Accounts = ' + accountsToUpdate.size());
            
        }
       update accountsToUpdate; 
        
    }
	 	
}

 
Hi...

We want to share a scratch org between two developers. How could we do?

Thanks
Dear Team ,

Greetings !!!

Thank you for your support . I have created one APEX class for SOAP service it contains one method to insert data into Account Standard object . Plz let me know how i call this class and metod through Workbench tool . This is my code

class name : accSOAPint 

global class accSOAPint {

    webservice static Account dopost(String Name){
        Account acc = new Account();
        acc.Name = Name;
        insert acc;
        return acc;
        
    }
}

Thanks & Regards
Sachin Bhalerao
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 All,

VERY new to salesforce and being an admin in general. I am trying to create a field on a custom object to provide "True" if the time the object was last modified is earlier than or equal to the current Date/Time. I created a custom field to provide the date and time last modified already and that is working as it should. I am using:

IF ( NOW() - Date_Time_Last_Modified__c <= 7200000 ,"TRUE", "FALSE" )

But it is returning True always even if the statement is not.  I am not sure if something is wrong with my formula?
I want to use a 'raw' URL to send a REST API call to SFDC e.g.:
https://my_salesforce_instance.com/services/data/v47.0/query?q=SELECT+id,name+FROM+user+WHERE+Alias='ebrow'&Bearer=<Token Value>
but I am getting "Invalid Session ID". Naturally I have verified the <Token Value> using PowerShell to initiate the call.
Is there a way/syntax where I can contain all the required information in a URL string so I can do the call directly from my browser?
Hello!  I'm completely new to Salesforce and need help.  Read a lot of the discussions but can't figure out what I need. 

Okay, so I have a picklist field named 'Action' with various options.. I'll just call them Option 1, 2, 3, etc. 

I need a formula that would do this: 
((Total of all options - (Option 1, Option 4 & Option 7)) / (Total of all options - Option 3) = %

Help!! Please :) 
Contoller :

public class AccountComponent
{
    @AuraEnabled
    
    public static string accsearch(string name,string phone)
    {
        system.debug(name);
        system.debug(phone);
        list<account>accList = new list<account>();
        account a = new account();
        a.name = name;
        a.phone = phone;
        accList.add(a);
        try
        {
            insert accList;
            return 'Successfully inserted';
        }
        catch(exception e)
        {
            system.debug(e);            
            return e.getMessage();
        }        
    }
}

Lightning Component :

<aura:component controller="AccountComponent" implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" >
    
    <aura:attribute name="Accountstatus" type="string"/>
    <aura:attribute name="AccountName" type="string"/>
    <aura:attribute name="Phone" type="string"/> 
    <lightning:input type="string" label="Enter Name" value="{!v.AccountName}"/>
    <lightning:input type="string" label="Enter Phone" value="{!v.Phone}"/>
    <lightning:button label="Save" onclick="{!c.accsearch}"/>
    
    {!v.Accountstatus}
    <br/>        
</aura:component>

Controller.js :
({
    accsearch : function(component, event, helper)
    {
        var action = component.get('c.accsearch');
        var name = component.get('v.AccountNam');
        action.setParams({name : name});
        var phone = component.get('v.Phone');
        action.setParams({phone : phone});      
        action.setCallback(this,function(response)
                           {
                               var getrecordstatus = response.getReturnValue();
                               component.set('v.Accountstatus',getrecordstatus);
                               console.log(':',getrecordstatus);
                           },'SUCCESS');
        $A.enqueueAction(action);
    }
})
I'm having trouble composing the right code for the following data model. Arrows represent lookup fields (A has lookups for B & C, D has lookup for C).diagram of objects A, B, C, D. A looks up B & C, and D also looks up C.
For each myA record in an A_object list, I need to read the stringB field from its corresponding B_object, create the list of D_objects related to the same C_object, and read their stringD fields.

Statements I tried that don't work:

string myB = myA.B__r.stringB; // returns null

for (D_object myD : [select Id,stringD from D_object where C = :myA.C__r.Id]) // SOQL returns 0 records

C_object myC = myA.C // syntax error: illegal assignment from Id
C_object myC = myA.C.Id // syntax error: non foreign key can't be refererence
C_object myC = myA.C__r.Id // syntax error: illegal assignment from Id
C_object myC = myA.C__r // returns null

What is the correct syntax?
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);
       
       
    },
    
})
So - I always get this error in VSCode - whenever I try to do of the SFDX commands...

Unexpected file found in package directory: /.../Icon

I've been using VSCode for several months now, and I've always got around this error by just going into every folder in the project and deleting the file "Icon".  But I'd like to find the root cause and fix it.

Anytime I build a new project - it will be a file canned "Icon" in every folder of the project.  Deleting the file takes care of the error - but now that I'm using more scratch org's and building more projects - it's becoming quite a bother.

Thoughts?

 
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?.
I am building a list of our preferred vendors and want to show it in a custom lightning web component. I would like all vendors of the same 'Category' to be listed together, with just one header. 
User-added image

As you can see, when there are multiple vendors in one cateogry, the category name/head displays twice. I am sure I could get what I need, through making multiple calls in apex (one for each category), but it seems ideal and more efficient to get all the vendors in one call, and then just adjust their grouping in the lightning web component. 

I query the data in the controller, then display it in the lwc as such: 
<template for:each={vendors.data} for:item="vendor">
                <div key={vendor.Id}>                   
                    <div class="slds-text-heading_small">{vendor.Category_Name__c}</div>
                    <p><lightning-formatted-rich-text value={vendor.Vendor__c} ></lightning-formatted-rich-text></p>
                </div>
            </template>

 
Does anyone know what happened to the Local Development Server for LWC? I used it for a few days, it was definetly buggy, but was good for quick wireframes.

I switched to a different PC, and it appears the package is gone, I tried sfdx plugins:install lwc-dev-server and it said plugin not found.
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
I have a LWC that is returning an sObject from APEX.  How do you display a field in the HTML?

my .js has...
import rtnSObjectRec from '@salesforce/apex/HelperAccount.rtnSObjectRec';

The APEX is:
@AuraEnabled (cacheable=true) 
	public static Account rtnSObjectRec(string recId) {
		Account sObjectRec = [SELECT id,name FROM Account WHERE Id = :recId];
		return sObjectRec;
	}

The HTML is:
<lightning-formatted-text value={sObjectRec.name.data}></lightning-formatted-text>

But the LWC doesn't display.  If I change the HTML to
<lightning-formatted-text value="testData"></lightning-formatted-text>
The lwc will display, and the "testData" will show.

Can anybody see what I'm doing wrong?

Thanks,

(I know I can just use the data service to get sObjects, I'm just trying to understand the syntax on the HTML side. Eventually, I want my APEX to return a custom sub-class)


 
I've built a Lightning Web Component and need to write a Jest unit test class for it. A part of the component only renders when a tracked property, called it "showDesktopView" is true. The default value is false. For a Jest test case to pass, the section needs to render. Therefore, I need a method that will result in "showDesktopView" being set to true. It is set to true when the UI theme isn't mobile.

The property:
@track showDesktopView = false;

I've tried the below appproaches of setting the property, but they don't work.
const element = createElement('c-test', { is: testLWC });
element.showDesktopView = "true";  //Trial 1
element.showDesktopView = true;    //Trial 2
document.body.setAttribute('showDesktopView','true');  //Trial 3
document.body.appendChild(element);


return Promise.resolve().then(() => {
// My promise code
});

They don't seem to work since my Promise fails. I know my code in the Promise works because if I set the property "showDesktopView" to a default value of true, then it passes.

Does anyone know how to correctly set this property from a Jest unit test?
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.