• 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'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}"))
)

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
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!





 
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!!