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

  • Chatter
    Feed
  • 402
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 0
    Questions
  • 2493
    Replies

I currently have this formula (below) but it does not allows me to save a phone number with the parenthesis. I want to be able to save the phone with or without the parenthesis. I want the user to be able to save the number in any of these formats: XXXXXXXXXX or XXX-XXX-XXXX or (XXX) XXX-XXXX or (XXX)XXX-XXXX.  All four ways. Is this possible? Witht the formula below I can save the first 2 formats but not the last 2. Thanks

AND(
OR(
ISNEW(),
ISCHANGED(Phone)
),
NOT(ISBLANK(Phone)),
NOT(REGEX(Phone, "\\D*?(\\d\\D*?){10}"))
)

  • April 11, 2022
  • Like
  • 0
I have a fairly simply program that I am using to retreive some records via Apex and then allow the user to filter them in the JS controller. I also have an Export List button that is currently allowing them to download the list they have filtered as a CSV file. The problem is that leading zeroes do not show up in Excel. This is not an LWC or Salesforce issue, but an issue with how Excel handles the data. I would like to create a real XLSX file. Is there a way to do this natively? Or will I need to use a third-party library? What would be the recommended library to use? xlsx.js?

Thanks,
Rebekah

handleExport() {
        let rowEnd = '\n';
        let csvString = '';
        this.exportHeader.forEach(element => {
            csvString += element + ',';
        });
        csvString += rowEnd;
        this.orders.forEach(record => {
            csvString += Customer__c + ',';
            csvString += '"' + record.ShipToLocationID__c + '",';
            csvString += '"' + record.PONumber__c + '",';
            if (record.POLineNumber__c == undefined) {
                csvString += ' ,';
            } else {
                csvString += record.POLineNumber__c + ',';
            }
            if (record.CustomerItemNumber__c == undefined) {
                csvString += ' ,';
            } else {
               csvString += '"' + record.CustomerItemNumber__c + '",';
            }
            csvString += '"' + record.ItemNumber__c + '",';
            csvString += '"' + record.CONumber__c + '",';
            csvString += '"' + record.ERP_ProductItem__r.ItemDescription__c + '",';
            csvString += record.PromisedDeliveryDate__c + ',';
            csvString += record.COLineNumber__c + ',';
            csvString += record.ItemOrderedQuantity__c + ',';
            csvString += record.OpenQuantity__c + ',';
            csvString += record.UnitPrice__c + ',';
            csvString += record.ExtendedPrice__c + ',';
            csvString += rowEnd;
        });
       
        var element = 'data:text/csv;charset=utf-8,' + encodeURIComponent(csvString);
        let downloadElement = document.createElement('a');
        downloadElement.href = element;
        downloadElement.target = '_self';
        downloadElement.download = 'Sales Order Lines.csv';
        document.body.appendChild(downloadElement);
        downloadElement.click();
    }
Hello all,
I have an aura component where I need to encrpty a string that contains vlaues from the component.  Can I do this within the component JS?  Or does the data need to be sent to a controller and then pulled back again?  I am encrypting  a string and sending it to an external site when a user saves their record.
Thank you,
P
  • April 07, 2022
  • Like
  • 0

Hi,

I'm trying to remove options in lightning:inputField but I didn't know how to do it.
User-added image

This TVN1Result__c returns Active, Cancelled, Draft, Completed. I would like to remove Active and Completed.

 

TVN1Result__c  is a controlling field of  TVN2Result__c dependent picklist field used in RecordEditForm.

 

I can't remove the options on record type because another page will use all the options.

TesterContainer.cmp
<aura:component implements="lightning:actionOverride,lightning:hasPageReference"> 
    <!-- Handler of init to execute actions on loading -->
    <aura:handler 	name="init" 	value="this" action="{!c.doInit}"/>
    <!-- LWC to handle all logic; has to be wrapped on aura component which implements lightning:actionOverride
         It is commented to simplify the example and avoiding useless noise
    <c:lWC_NewContactOverriden>
    -->    
</aura:component>
TesterContainerController.js
({
    doInit : function(component, event, helper) {
        console.log('Start doInit');
        $A.get("e.force:closeQuickAction").fire();
    }
})

On contact override New Action with this component
Setup->Object Manager->Contact->Buttons Links and Actions ->New

 typeUser-added image

Attention: Skip record type selection page is Checked.

Please run this example on contact related list on account.
Open console on your browser developer tools.

Click on the New button to run the component as below:

User-added image

You will see on console the result of executing doInit. Console will show:
"Start doInit"

The screen will be blue cos there is no visual components on markup file TesterContainer.cmp.

Now navigate again to account page but DON'T RELOAD the page on browser. Just go back to the previous page, so the account page is shown again.

Press again on New button as before:

You will see on console that doInit() method doesn't run!

Can't find why, cos I was careful to close the component and it should be destroyed as:

https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/ref_jsapi_component_destroy.htm

Please help cos I'm waisting tons of time and I'm with no ideas.

Thanks in Advance!





 
Hi All, 

So i've been learning LWC, and got to the topic of using 3rd party library. i'm curious as to how do we know what function name to use in the 3rd library.

For example, i'm using axios to fetch data from external server
link: https://github.com/axios/axios
I'm configuring the js file of lwc, loadScript to point to '/axios-master/dist/axios.js'

I can call the function, namely axios({ url: ...}).then().catch()
But when i inspect the file axios.js inside folder dist, nowhere i can find the function with name axios, there is function with name Axios though (capitalized first letter). The curious thing is, if i call function Axios, it doesn't work in lwc.

Can somebody help to explain this to me, as i'm very curious how to know the function name to use.

Thank you very much friends.
Maybe I've just been staring at this for too long, but I can't find what it is I'm missing. Would anyone be willing to take a look with fresh eyes and make suggestions?

When I click "Check Syntax" it highlights the word "One" in one of the text field values and shows the Error: Syntax error. Missing ')'

I want the checkbox field to be marked as true when any of the conditions are met. each segment before the or sign "||", is one condition.

Got any ideas, please share. Thanks!

( (TEXT(Years_Since_Bankruptcy_Discharged__c) = "Yes" && TEXT( Re_established_credit_after_bankruptcy__c ) = "Yes") || (TEXT(Bankruptcy__c) = "No") || (TEXT(Years_Since_Bankruptcy_Discharged__c) = "One to two years since bankruptcy discharged" && TEXT( Re_established_credit_after_bankruptcy__c) = "I have not made more than one late payment in the past year”) ||(TEXT(Years_Since_Bankruptcy_Discharged__c) = "One to two years since bankruptcy discharged" && TEXT( Re_established_credit_after_bankruptcy__c) = "I have not made more than two late payments in the past two years")|| (TEXT(Years_Since_Bankruptcy_Discharged__c) = "More than two years since bankruptcy discharged" && TEXT( Re_established_credit_after_bankruptcy__c) = "I have not made more than one late payment in the past year”) || (TEXT(Years_Since_Bankruptcy_Discharged__c) = "More than two years since bankruptcy discharged" && TEXT( Re_established_credit_after_bankruptcy__c) = "I have not made more than two late payments in the past two years”) )
 
Hi All,

Here I have a Batch Apex class which uses an API to get some random contacts. This all works perfectly fine and I am happy with it,

I wanted to trigger this with a user input via a LWC. I created BatchCreateContactController to do this.

Calling BatchCreateContactController from the Developer sonsole works, but my LWC won't call it. I suspect it is something to do with the LWC JS file. Unsure.

I am getting an error when I run CLI commands after creating a project: Cannot read property 'getInstance' of undefined

 

I am suddenly unable to do any CLI commands with both existing and new projects. The only thing I can do is create the initial project. Everything else gives me this error.

 

Here's the error in the console:

 

console.ts:137 [Extension Host] {
"status": 1,
"name": "TypeError",
"message": "Cannot read property 'getInstance' of undefined",
"exitCode": 1,
"commandName": "ConfigGetCommand",
"stack": "TypeError: Cannot read property 'getInstance' of undefined\n at ConfigGetCommand.hooksFromLifecycleEvent (/Users/alaricwimer/.local/share/sfdx/node_modules/salesforce-alm/node_modules/@salesforce/command/lib/sfdxCommand.js:401:44)\n at ConfigGetCommand.init (/Users/alaricwimer/.local/share/sfdx/node_modules/salesforce-alm/node_modules/@salesforce/command/lib/sfdxCommand.js:248:20)\n at async ConfigGetCommand._run (/Users/alaricwimer/.local/share/sfdx/node_modules/salesforce-alm/node_modules/@salesforce/command/lib/sfdxCommand.js:92:13)\n at async Config.runCommand (/Users/alaricwimer/.local/share/sfdx/client/7.69.0-c7be45ae22/node_modules/@oclif/config/lib/config.js:172:9)\n at async Main.run (/Users/alaricwimer/.local/share/sfdx/client/7.69.0-c7be45ae22/node_modules/@oclif/command/lib/main.js:22:9)\n at async Main._run (/Users/alaricwimer/.local/share/sfdx/client/7.69.0-c7be45ae22/node_modules/@oclif/command/lib/command.js:43:20)\n at async Object.run (/Users/alaricwimer/.local/share/sfdx/client/7.69.0-c7be45ae22/dist/cli.js:32:20)\nOuter stack:\n at Function.wrap (/Users/alaricwimer/.local/share/sfdx/node_modules/salesforce-alm/node_modules/@salesforce/core/lib/sfdxError.js:151:27)\n at ConfigGetCommand.catch (/Users/alaricwimer/.local/share/sfdx/node_modules/salesforce-alm/dist/ToolbeltCommand.js:247:46)\n at async ConfigGetCommand._run (/Users/alaricwimer/.local/share/sfdx/node_modules/salesforce-alm/node_modules/@salesforce/command/lib/sfdxCommand.js:97:13)\n at async Config.runCommand (/Users/alaricwimer/.local/share/sfdx/client/7.69.0-c7be45ae22/node_modules/@oclif/config/lib/config.js:172:9)\n at async Main.run (/Users/alaricwimer/.local/share/sfdx/client/7.69.0-c7be45ae22/node_modules/@oclif/command/lib/main.js:22:9)\n at async Main._run (/Users/alaricwimer/.local/share/sfdx/client/7.69.0-c7be45ae22/node_modules/@oclif/command/lib/command.js:43:20)\n at async Object.run (/Users/alaricwimer/.local/share/sfdx/client/7.69.0-c7be45ae22/dist/cli.js:32:20)",
"warnings": []
}

 

Does anyone know how I can fix this?

Hello,

I'm able to query the Metadata API with JSforce and my credentials.

I would like to run it in a cron on a web server.
Is there a way to generate a access key (like on aws) so that I don't need to put my username/password on the server?

Thx
Baptiste
experts ,
I have two date time field values 

submitted date =date time
released date=date time
total time field is formula return type is number .

for total time i have put like below 
released date - submitted date 

now result is showing only on days .
i want result should show days ,hours ,minutes 

can some one guide if we can do ?
like result is showing 27.56 days 
i want it to be 27 days 12 hours and 86 minutes something like this
 
Hi, I'm trying to create an LWC that displays a datatable of records from a custom obect called Match__c. I want to display the record Id, the participant, and volunteer fields in the datatable where the field volunteer job on the Match record equals the record id of the page being viewed. I created an apex controller to pull the data. The table will not display any data even though I have permissions to the object/fields. On load the console displays "DevTools Failed to Load Source Map". Here are some pictures: 

Apex Controller
User-added imageJS
User-added imageHTML
User-added imageComponent
User-added image
Any help would be appreciated. This is my first LWC.
Hello
I'm trying to get the Week Number into a new custom field.  I need to calculate the week number from a standard Field Service Lightning field named "SchedStartTime".  The data type for this field is Date/Time.  I created a custom formula field to capture only the date from the SchedStartTime field named "Scheduled Start Date" with the formula: DATEVALUE(SchedStartTime ).  I then created another custom field named "Week Number" with the formula: MOD (FLOOR (( Scheduled_Start_Date__c - DATE(2019,12,30) + (1/24) ) / 7),53)+1.  However, there are errors when the Scheduled Start is midnight (00:00), the Week Number should update to the next week number but this isn't happening until the Scheduled Start is 01:00.  See example below:

Scheduled Start     Week Number
14/06/2020 23:00          24
14/06/2020 23:30          24
15/06/2020 00:00          24
15/06/2020 00:30          24
15/06/2020 01:00          25

Can anyone provide help please?  Note that our Org has the Default Time Zone(GMT+01:00) British Summer Time (Europe/London).

I have an interesting use case. We are using Salesforce's Embedded Chat service, but it needs to also be able to open by the click of a button located somewhere on the page.

This means it opens in two ways:

1. The standard way (clicking the embedded chat in the bottom right of the screen)

2. A separate button on the page that should open that same embedded chat

 

I already know that using Chat Buttons and Embedded Chat on the same page is not compatible with Salesforce. However, is it possible to lauch the Embedded Chat with a button click? Essentially, we just need two ways to launch the embedded chat: button click on page, and standard way

Hi -

I have a VF page that generates what we call Route Sheets.  Each one takes 1-2 pages and the whole printout is about 55 pages long.  Each Route starts on a new page.  This is all fine.

The challenge is -- I'd like to include the route name on every page so was thinking of placing it in the page footer.  To accomplish this I'd need to change the footer with each iteration through the loop.

Can that be done?  If not, do you have other suggestions?

Thanks,

Steve

 
<apex:page controller="GenerateRouteSheets" deferLastCommandUntilReady="true" renderAs="PDF" applyBodyTag="false" action="{!loadData}">
	<!-- <apex:page controller="GenerateRouteSheets" deferLastCommandUntilReady="true" renderAs="PDF" applyBodyTag="false" > -->
	<head>
		<style>
			@page{
			size: landscape;
			@bottom-right {
			font-family: 'Arial Unicode MS';
			font-size: 13px;
			content:  "Page " counter(page) " of " counter(pages);
			}
			} 
		</style>
	</head>
	<script>
	    var dt = new Date();
	    document.getElementById("datetime").innerHTML = dt.toLocaleString();
	</script>
	<body>
		<apex:pageBlock >
			<apex:repeat value="{!routes}" var="r">
				<div style="page-break-after:always;  ">
                    Route {!r}
                    ~~ SNIP ~~
                </div>
			</apex:repeat>
		</apex:pageBlock>
	</body>
</apex:page>

 
I need to show a picklist in a visualforce with all the related territories of an user. These territories are the user's assigned territories and all the territories under them in the territory hierarchy. For example, with a hierarchy like this one:
Europe
 |- France
 |- Spain <--
   |- Madrid
   |- Catalunya
     |- Barcelona
 |- Italy
A user assigned to Spain should see Madrid, Catalunya and Barcelona as possible options in the picklist. Right now I achieve this using a recursive function, but in a production org with around 1300  territories, I'm hitting CPU and SOQL limits all the time because I need to execute a SOQL query for every sub territory.

Reading Enterprise Territory Management documentation I cannot find any function provided by Salesforce to achieve this and the object itself doesn't have a named relationship between the parent a its sons that could help me reduce the number of queries. I was looking something like this:
SELECT Id, Name, (SELECT Id, Name FROM ChildTerritory2s) FROM Territory2 WHERE DeveloperName = 'Spain'
Hope someone have some workaround for achieving this without using something as demanding as a recursive function that when it hits the limits doesn't show the end of the list. Thanks.
I've got the following code
 
User u =   [SELECT Id 
            FROM User
            Where Email='admin@***.org'];

for(AggregateResult objAgr : [SELECT   RecordType.Name, SUM(DurationHours__c)
                              FROM     Event 
                              WHERE    OwnerId = :u.Id
                              GROUP BY RecordType.Name])
{
    String label = string.valueof(objAgr.get('RecordType.Name'));
    Double total = double.valueof(objAgr.get('expr0'));
    system.debug(label + ' | ' + total);
}

I get an error when running this from an execute anonymous window that says:

System.SObjectException: Invalid field RecordType.Name for AggregateResult

I am able to use this exact same code for a similar query, except instead of grouping by RecordType.Name, I group by ActivityDate. This works perfectly. So how do I get RecordType.Name results?
Hey guys, there is a text field that I want to restrict so it only accepts 10 digit phone numbers separated by commas. 

So far I have this, but it does not specify how many digits the numbers must be.  So it allows any number of digits separated by commas (i.e. 123,12,1234,12345,etc).  But I want to restrict it to comma separated 10-digit numbers (i.e. 4161231234,6470987657,9051231234,etc…).  I know I need a “{10}” somewhere, but can’t seem to figure out where. 

Your help is greatly appreciated.


AND(
NOT(ISBLANK(Text_Field__c)),
NOT(REGEX(Text_Field__c,"^[0-9,.*]+$"))
)
Hello, I need to query a feeditem's parent's custom field.

Here is so far:
  
            Discharge__c discharge=[Select Id, Name, Date_of_Birth__c from Discharge__c where Id = :this.dis.id];
        
        listofNotes = [SELECT ID, CreatedDate, CreatedById, CreatedBy.FirstName, CreatedBy.LastName, ParentId, Parent.Name, Body
                      FROM feeditem 
                      WHERE Parent.Name = :discharge.name ];

I need to add another WHERE clause stating that the Parent (discharge record's) date of birth  is = discharge.date_of_birth__c

Is this possible?
Hi,

Can anyone please help how to cover a test class for this code ?
 
public class GD_CartProductsWrapper {

    @AuraEnabled
    public GD_Cart__c cartItem;
    
    @AuraEnabled
    public List<String> uomPicklist;
    
    @AuraEnabled
    public Map<String,GD_Cart__c> orderLinesByUom;
    
    @AuraEnabled
    public Decimal unitPrice;
    
    @AuraEnabled
    public Decimal totalPrice;
    
    public GD_CartProductsWrapper(){
        cartItem = new GD_Cart__c();
        uomPicklist = new List<String>();
        orderLinesByUom = new Map<String,GD_Cart__c>();
        totalPrice = 0;
    }
}

Regards,
Soundar.​​​​​​​
I'm pretty new and I'm playing with the flows. 
I have a subject of the case (generated via mail to the case) that is like this
NRT_N_22F26234-55_pier_T_delivery
It might be also 
N_22F26234-55_pier_T_delivery
or
22F26234-55_pier_T_rejected
I would like to extract
22F26234-55

my idea is to use regex expression ([0-9]+F[0-9]+-[0-9]+) to identify the position of the regex string... is it possible???

grazie

I currently have this formula (below) but it does not allows me to save a phone number with the parenthesis. I want to be able to save the phone with or without the parenthesis. I want the user to be able to save the number in any of these formats: XXXXXXXXXX or XXX-XXX-XXXX or (XXX) XXX-XXXX or (XXX)XXX-XXXX.  All four ways. Is this possible? Witht the formula below I can save the first 2 formats but not the last 2. Thanks

AND(
OR(
ISNEW(),
ISCHANGED(Phone)
),
NOT(ISBLANK(Phone)),
NOT(REGEX(Phone, "\\D*?(\\d\\D*?){10}"))
)

  • April 11, 2022
  • Like
  • 0
I have a fairly simply program that I am using to retreive some records via Apex and then allow the user to filter them in the JS controller. I also have an Export List button that is currently allowing them to download the list they have filtered as a CSV file. The problem is that leading zeroes do not show up in Excel. This is not an LWC or Salesforce issue, but an issue with how Excel handles the data. I would like to create a real XLSX file. Is there a way to do this natively? Or will I need to use a third-party library? What would be the recommended library to use? xlsx.js?

Thanks,
Rebekah

handleExport() {
        let rowEnd = '\n';
        let csvString = '';
        this.exportHeader.forEach(element => {
            csvString += element + ',';
        });
        csvString += rowEnd;
        this.orders.forEach(record => {
            csvString += Customer__c + ',';
            csvString += '"' + record.ShipToLocationID__c + '",';
            csvString += '"' + record.PONumber__c + '",';
            if (record.POLineNumber__c == undefined) {
                csvString += ' ,';
            } else {
                csvString += record.POLineNumber__c + ',';
            }
            if (record.CustomerItemNumber__c == undefined) {
                csvString += ' ,';
            } else {
               csvString += '"' + record.CustomerItemNumber__c + '",';
            }
            csvString += '"' + record.ItemNumber__c + '",';
            csvString += '"' + record.CONumber__c + '",';
            csvString += '"' + record.ERP_ProductItem__r.ItemDescription__c + '",';
            csvString += record.PromisedDeliveryDate__c + ',';
            csvString += record.COLineNumber__c + ',';
            csvString += record.ItemOrderedQuantity__c + ',';
            csvString += record.OpenQuantity__c + ',';
            csvString += record.UnitPrice__c + ',';
            csvString += record.ExtendedPrice__c + ',';
            csvString += rowEnd;
        });
       
        var element = 'data:text/csv;charset=utf-8,' + encodeURIComponent(csvString);
        let downloadElement = document.createElement('a');
        downloadElement.href = element;
        downloadElement.target = '_self';
        downloadElement.download = 'Sales Order Lines.csv';
        document.body.appendChild(downloadElement);
        downloadElement.click();
    }

Hi,

I'm new to LWC and I'm trying to connect to apex class to get data from a custom object, and I got these error: Error during LWC component connect phase: [e[Nn] is not a function]

Here are my code:
NewApplication.js

import { LightningElement, api, wire } from 'lwc';
import getNewApplications from '@salesforce/apex/HelperNewApp.getNewApplications';

export default class NewApplication extends LightningElement {
    //@wire (getApplicationStatus) appStatus;
    @api newApps;
    @api error;

    @wire (getNewApplications, {status: "New"}) 
    wiredNewApplications(data,error){
        if (data) {
            this.newApps = data;
            // eslint-disable-next-line no-console
            console.log('DATA => ', data, JSON.stringify(data));
        } else if (error) {
            this.error = error;
            console.log('ERRor => ', error, JSON.stringify(error));
        }
    };

    
   
}

NewApplication.html
<template>
    <div class="container">
        <h1>New Agent Applications</h1>

        <div>
            <template if:true = {newApps}>
                
                <template for:each={newApps} for:item="app">
                    {app.Name}                    
                </template>
            </template>
            <template if:true = {error}>
                Error: {error}
            </template>
        </div>

    </div>
</template>

HelperNewApp.cls
public with sharing class HelperNewApp {
    @AuraEnabled(cacheable=true)
    public static List<Agent_Application__c> getNewApplications(String status) {

        return [SELECT Id, Name, Primary_Contact_Name__c,
                    Company_Name__c, Status__c, CreatedDate
                        FROM Agent_Application__c
            WHERE Status__c = :status
            ORDER BY CreatedDate];
    }
}


Thanks,
Hello all,
I have an aura component where I need to encrpty a string that contains vlaues from the component.  Can I do this within the component JS?  Or does the data need to be sent to a controller and then pulled back again?  I am encrypting  a string and sending it to an external site when a user saves their record.
Thank you,
P
  • April 07, 2022
  • Like
  • 0
Hi Team,

I built this formula a few years ago and it's time to update it.
I was not able to make it worth just using the MM and DD values, which would be sustainable and shorter.

It's basically checking if the release date (Invoice sent date) is in between our specific payout schedule. 

Pay out Calendar

Any advice is greatly appreciated!

Formula field currently:

IF( cld__ReleaseDate__c < DATE(2019,01,01), cld__ReleaseDate__c ,
IF( cld__Date2__c < DATE(2019,01,01) && cld__ReleaseDate__c >= DATE(2019,01,01), cld__ReleaseDate__c ,
IF( cld__ReleaseDate__c >= DATE(2019,01,01) && cld__ReleaseDate__c <= DATE(2019,04,10), DATE(2019,04,01),
IF( cld__ReleaseDate__c >= DATE(2019,04,11) && cld__ReleaseDate__c <= DATE(2019,07,10), DATE(2019,07,01),
IF( cld__ReleaseDate__c >= DATE(2019,07,11) && cld__ReleaseDate__c <= DATE(2019,10,10), DATE(2019,10,01),
IF( cld__ReleaseDate__c >= DATE(2019,10,11) && cld__ReleaseDate__c <= DATE(2020,01,10), DATE(2020,01,01),
IF( cld__ReleaseDate__c >= DATE(2020,01,11) && cld__ReleaseDate__c <= DATE(2020,04,10), DATE(2020,04,01),
IF( cld__ReleaseDate__c >= DATE(2020,04,11) && cld__ReleaseDate__c <= DATE(2020,07,10), DATE(2020,07,01),
IF( cld__ReleaseDate__c >= DATE(2020,07,11) && cld__ReleaseDate__c <= DATE(2020,10,10), DATE(2020,10,01),
IF( cld__ReleaseDate__c >= DATE(2020,10,11) && cld__ReleaseDate__c <= DATE(2021,01,10), DATE(2021,01,01),
IF( cld__ReleaseDate__c >= DATE(2021,01,11) && cld__ReleaseDate__c <= DATE(2021,04,10), DATE(2021,04,01),
IF( cld__ReleaseDate__c >= DATE(2021,04,11) && cld__ReleaseDate__c <= DATE(2021,07,10), DATE(2021,07,01),
IF( cld__ReleaseDate__c >= DATE(2021,07,11) && cld__ReleaseDate__c <= DATE(2021,10,10), DATE(2021,10,01),
IF( cld__ReleaseDate__c >= DATE(2021,10,11) && cld__ReleaseDate__c <= DATE(2022,01,10), DATE(2022,01,01),
null
))))))))))))))


 

Hi,

I'm trying to remove options in lightning:inputField but I didn't know how to do it.
User-added image

This TVN1Result__c returns Active, Cancelled, Draft, Completed. I would like to remove Active and Completed.

 

TVN1Result__c  is a controlling field of  TVN2Result__c dependent picklist field used in RecordEditForm.

 

I can't remove the options on record type because another page will use all the options.

Hello anywone! 
I'm getting the error 

"Malformed JSON: Expected '[' at the beginning of List/Set" when my Integration tryes to cath a result of a external system.

The return of the API is:
[
    {
        "idGeral": 1000021541136,
        "dtAtz": "2014-08-07 15:42:40.0",
        "cdGrupoSimilarItem": 1466,
        "itens": [
            {
                "preco": 0,
                "flPromocao": false,
                "pcMaxDescontoAut": 0,
                "ipi": 0,
                "st": 0,
                "ipiSt": 0,
                "idItem": 1027,
                "cdItem": "10070300",
                "nmItem": "JUNTA CABEÇOTE H100/L200/HR/K2500 2.5 8V FIBRA 1.55MM 4 PIC*",
                "nmReduzido": "JUNTA CABEÇOTE H100 2.5 8V 97/... L200 2.5 8V 92/../02 / HR/K2500 2.5 8V 05/../12 FIBRA 1.55MM 4 PIC",
                "curvaAbc": "A",
                "curvaAbcForn": "C",
                "flAtivo": "S",
                "cdGrupo": 110,
                "cdSubgrupo": 1,
                "unMedCompra": "UNID",
                "unMedArmazenagem": "PC",
                "unMedEstoque": "PC",
                "unMedVenda": "PC",
                "cdLinhaProduto": 4,
                "cdOriginal": "",
                "cdMarca": 1,
                "cdFabricante": "10070300",
                "fichaTecnica": "DIAMETRO PISTÃO 92,50 MMESPESSURA 1,55 MMALTURA DO PISTÃO A PARTIR DE 0,680 ATÉ 0,744 MM",
                "qtAtual": 12.0,
                "cstOrigem": "",
                "obs": "Teste",
                "obsConferenciaSaida": "",
                "obsEmbalagem": "",
                "obsCompras": "\r\n",
                "obsFichaTecnica": "DIAMETRO PISTÃO 92,50 MMESPESSURA 1,55 MMALTURA DO PISTÃO A PARTIR DE 0,680 ATÉ 0,744 MM",
                "nmMarca": "AJUSA",
                "estoqueDisponivel": true,
                "temSimilares": true
            }
        ],

        "codigos": [
            {
                "codigo": "2231142855",
                "descricao": "ORIGINAL"
            }
        ]
    }
]

The req is:
HttpResponse res = h.send(req);
                System.debug(res.getBody());
                String s = res.getBody();
                retorno = (List<SimilarWrapper>)System.JSON.deserialize(s, List<SimilarWrapper>.class);
The classes are: 

public class SimilarWrapper{
        public Long idGeral {get;set;}
        public String dtAtz {get;set;}
        public Integer cdGrupoSimilarItem {get;set;}
        public List<IntegracaoProdutoUtils.ProdutoWrapper> itens {get;set;}
        public List<CodigoWrapper> codigos {get;set;}

    public class CodigoWrapper{
        @AuraEnabled
        public String codigo {get;set;}  
        @AuraEnabled      
        public String descricao {get;set;}        
    }

The second wrapper (IntegracaoProdutoUtils.ProdutoWrapper) is:

public static List<Product2> ProdutoConstruct(List<ProdutoWrapper> produtos){
        
        List<Product2> ret = new List<Product2>();               
        
        for(ProdutoWrapper produto: produtos){
            
            Product2 pt = new Product2(); 
            pt.nvpreco__c = produto.preco;
            pt.nvflPromocao__c = produto.flPromocao;
            pt.nvpcMaxDescontoAut__c = produto.pcMaxDescontoAut;
            pt.nvipi__c = produto.ipi;
            pt.nvst__c = produto.st;
            pt.nvipiSt__c = produto.ipiSt;
            pt.IdGeral__c = produto.idItem;
            pt.CodigoProduto__c = produto.cdItem;
            pt.CodigoItem__c = produto.cdItem;
            pt.Name = produto.nmItem;
            pt.NomeReduzido__c = produto.nmReduzido;
            pt.CurvaABCImpave__c = produto.curvaAbc;        
            pt.CurvaABCFornecedor__c = produto.curvaAbcForn;
            if (produto.flAtivo.tolowercase() == 's'){
                pt.Ativo__c = true;
            }else{
                pt.Ativo__c = false;
            }
            if (produto.cdGrupo != null) {
                Grupo__c grupo = new Grupo__c(CodigoGrupo__c = produto.cdGrupo);
                pt.Grupo__r = grupo;          
            } 
            if (produto.cdGrupo != null && produto.cdSubgrupo != null) {
                Subgrupo__c subgrupo = new Subgrupo__c(CodigoSubGrupo__c = '' + produto.cdGrupo + produto.cdSubgrupo);            
                pt.Subgrupo__r = subgrupo;
            }
            pt.UnidadeCompra__c = produto.unMedCompra;
            pt.UnidadeArmazenagem__c =  produto.unMedArmazenagem;
            pt.UnidadeEstoque__c = produto.unMedEstoque;
            pt.UnidadeVenda__c = produto.unMedVenda;
            pt.CodigoLinhaProduto__c = produto.cdLinhaProduto != null ? Decimal.valueOf(produto.cdLinhaProduto) : null;
            pt.CodigoOriginal__c = produto.cdOriginal;
            if (produto.cdMarca != null) {     
                Marca__c marca = new Marca__c(CodigoMarca__c = produto.cdMarca);            
                pt.Marca__r = marca;
            }
            pt.CodigoFabricante__c = produto.cdFabricante; 
            // não achei campo no Product2 para bater com: fichaTecnica            
            pt.nvqtAtual__c = produto.qtAtual;
            //if(produto.qtAtual != null && produto.qtAtual != ''){
                //pt.Quantidade__c = Decimal.valueOf(produto.qtAtual);} 
            pt.nvcstOrigem__c = produto.cstOrigem;
            pt.nvobs__c = produto.obs;
            pt.nvobsConferenciaSaida__c = produto.obsConferenciaSaida;
            pt.obsEmbalagem__c = produto.obsEmbalagem;
            pt.obsCompras__c = produto.obsCompras;
            pt.obsFichaTecnica__c = produto.obsFichaTecnica;
            pt.nvnmMarca__C = produto.nmMarca;
            pt.nvestoqueDisponivel__c = produto.estoqueDisponivel;
            pt.nvtemSimilares__c = produto.temSimilares;
            pt.Integrado__c = true;
            // pt.QuantidadeImagens__c = produto.qtImagem;
            //if(!ret.contains(pt)){
            ret.add(pt);
            //}
            
        }
        
        return ret;
    }
TesterContainer.cmp
<aura:component implements="lightning:actionOverride,lightning:hasPageReference"> 
    <!-- Handler of init to execute actions on loading -->
    <aura:handler 	name="init" 	value="this" action="{!c.doInit}"/>
    <!-- LWC to handle all logic; has to be wrapped on aura component which implements lightning:actionOverride
         It is commented to simplify the example and avoiding useless noise
    <c:lWC_NewContactOverriden>
    -->    
</aura:component>
TesterContainerController.js
({
    doInit : function(component, event, helper) {
        console.log('Start doInit');
        $A.get("e.force:closeQuickAction").fire();
    }
})

On contact override New Action with this component
Setup->Object Manager->Contact->Buttons Links and Actions ->New

 typeUser-added image

Attention: Skip record type selection page is Checked.

Please run this example on contact related list on account.
Open console on your browser developer tools.

Click on the New button to run the component as below:

User-added image

You will see on console the result of executing doInit. Console will show:
"Start doInit"

The screen will be blue cos there is no visual components on markup file TesterContainer.cmp.

Now navigate again to account page but DON'T RELOAD the page on browser. Just go back to the previous page, so the account page is shown again.

Press again on New button as before:

You will see on console that doInit() method doesn't run!

Can't find why, cos I was careful to close the component and it should be destroyed as:

https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/ref_jsapi_component_destroy.htm

Please help cos I'm waisting tons of time and I'm with no ideas.

Thanks in Advance!





 
The clear answer is No.
Reason Behind ?
Hi All, 

So i've been learning LWC, and got to the topic of using 3rd party library. i'm curious as to how do we know what function name to use in the 3rd library.

For example, i'm using axios to fetch data from external server
link: https://github.com/axios/axios
I'm configuring the js file of lwc, loadScript to point to '/axios-master/dist/axios.js'

I can call the function, namely axios({ url: ...}).then().catch()
But when i inspect the file axios.js inside folder dist, nowhere i can find the function with name axios, there is function with name Axios though (capitalized first letter). The curious thing is, if i call function Axios, it doesn't work in lwc.

Can somebody help to explain this to me, as i'm very curious how to know the function name to use.

Thank you very much friends.
Hey all,

Hope all is well! I wanted to ask for a huge favor here with the workday formula.

I am looking for a formula that will calculate 6 days in the past from the start date.

Out of the 6 total count days:
Day 0: cannot count Saturday, Sunday or Holiday's
Day 1-3: cannot count Sunday or Holiday's
Day 4-6: cannot count Saturday, Sunday or Holiday's

However, the final result can only land on a Monday-Friday and not on a holiday, saturday or sunday

So if it did land on a Holiday, Saturday or Sunday, the end date would revert to the previous workday

Example:
If start date is 1/18/2022, should return 1/7/2022, NOT 1/10/2022
Day 0: 1/7 (return date) since Day 0 cannot be a Sunday (see above), so the return date should revert to the previous workday (1/7/2022)
Day 1: 1/10
Day 2: 1/11
Day 3: 1/12
Day 4: 1/13
Day 5: 1/14
Day 6: 1/18 (start date)

1/15 doesnt count since its a Saturday
1/16 doesnt count since its a Sunday
1/17 doesnt count since its a Holiday (MLK Jr)

Here is the WORKING formula in excel: 
=if(B7="CA", WORKDAY(WORKDAY.INTL(WORKDAY(AF7,-3,$A$2:$A$13),-3,11,$A$2:$A$13)+1,-1,$A$2:$A$13), AF7-4)
 

In the Loan Object in Salesforce:

B7 = ‘Property State’ loan field 

AF7 = ‘Close of Escrow’ loan field

$A$2:$A$13 = Current Holiday Date List below:

1/17/2022 MLK
2/21/2022 Presidents
5/30/2022 Memorial
6/20/2022 Juneteenth
7/4/2022 Independence
9/5/2022 Labor Day
10/10/2022 Columbus
11/11/2022 Veterans
11/24/2022 Thanksgiving
11/25/2022 Day After Thanksgiving
12/26/2022 Christmas
1/2/2023 New Years
 
Would want to translate this formula into a Salesforce formula

Your help would be greatly appreciated!!
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.