+ Start a Discussion
亮 山崎亮 山崎 

Hi All

Id like to inform  message when user saved.

The Screnn is Standard Screen and Standard Button(New ,Edit, ・・・)

Would you teach me 「How to inform message on standard screen when saving」?

Except Validation Rules.
Because Validation Rules become error message .not information.

 

 

Best Answer chosen by 亮 山崎
VinayVinay (Salesforce Developers) 
Yes would recommend to build and use custom page to display or tweek messages as per your requirement.

Thanks,
Brett Roberts 15Brett Roberts 15 
I need to create a custom formula field on the account that evaluates the owner ID of an account and then fills a field out with a text value (a name).

Here is the breakdown I need.

Owner ID 1 = Name 1
Owner ID 2 & 3 = Name 2
Owner ID 3 & 4 = Name 3

Any ideas?
Best Answer chosen by Brett Roberts 15
Sai PraveenSai Praveen (Salesforce Developers) 
Hi Brett,

Thanks for confirming. Can you try thr below formula. Replace the ownerids as per your requirement.
 
if( OwnerId ='0055j000000XLmV', 'sample1' , if( OR(OwnerId ='0055j000000XERR',OwnerId ='0055j000000XERT'),'SAMPLE2', IF(OwnerId='0055j000000Xfs4', 'SAMPLE3','')

)

)

If this solution helps, Please mark it as best answer.

Thanks,
 
Phuc Nguyen 18Phuc Nguyen 18 
Hello All,
Is there a way to configure sf to sf to be enabled when you build a scracth org? Like I knolw you can enable communities by adding the config in a json sile so I was wondering if we could do the same for the sf to sf feeature.

Thank you,
P
Best Answer chosen by Phuc Nguyen 18
AbhinavAbhinav (Salesforce Developers) 
I think unfortunately not you have to enable it manually after creation of scratch org and then push you code related with Sf to Sf.
Axel TrocheAxel Troche 
Hello. Starting February 1, 2022, Salesforce will require customers to use MFA to access Salesforce products. My question is the following, the only way to perform the second authentication will be through the Salesforce Authenticator app? Or can it be done, for example, by email with a verification code?
Best Answer chosen by Axel Troche
VinayVinay (Salesforce Developers) 
Hi Axel,

Salesforce supports these types of verification methods.
  • Salesforce Authenticator mobile app : Fast free authentication sfdc.co/IntrotoAuthenticator
  • Third-Party Authenticator App : Such as: Google Authenticator, Microsoft Authenticator, Authy
  • Security Key : Such as: Yubico’s Yubi Key Google’s Titan Security Key

Not Supported below option
  • SMS (Text) verification : Two-factor authentication by SMS is a less secure option, and is available to use only with communities, partners, and customers. Contact Salesforce Customer Support to enable
  • Email verification
Reference: 
https://help.salesforce.com/s/articleView?id=000356005&type=1

Please mark as Best Answer if above information was helpful.

Thanks,
Rossa ChuRossa Chu 
Normally, there have a "New" button under the Fields & Relationships in an object. However, I cannot find this New" button under "Task" object.
How can I create a new field for it?
User-added image
Best Answer chosen by Rossa Chu
Sai PraveenSai Praveen (Salesforce Developers) 
Hi Rossa,

For Task and Event object you wont have ability to create new fields. Instead you need to creare the fields in Activity object and add those field to the event and task layout. 

If this solution helps, Please mark it as best answer.

Thanks,
Phuc Nguyen 18Phuc Nguyen 18 
Hello All,
I am trying to pass a value from @wire to the connectedCallback
 
import PRICE_FIELD from '@salesforce/schema/Order__c.Price__c';
 
@wire(getRecord, { recordId: '$recordId', fields: [PRICE_FIELD] })
  record;
I tried this within the connectedcallback but no value
this.priceId = this.record.data ? getFieldValue(this.record.data, PRICE_FIELD) : '';

So process flow is 
  1. @wire
  2. callback
  3. @wire

So at step 3 the @wire gets a value but not a step 1
What am I doing wrong?

Thank you,
P
 
Best Answer chosen by Phuc Nguyen 18
Piyush jadavPiyush jadav

Create one container div inside template tag and add attributes lwc:dom="manual" in your html file

<template> <div class="container" lwc:dom="manual"></div> </template>

Bhanu K NBhanu K N 
Hi,
I am trying to update a record via API request, I have added everything as needed but I always end up getting a 404 error.
User-added imageI am getting the Object ID value from here:
User-added imageAny help is highly appreciated. 

Thank you. 
Best Answer chosen by Bhanu K N
Maharajan CMaharajan C
Hi Bhanu,

Please reduce the version number to v53.0 in URL

I hope you are using the correct object api name and record id... Because Id starts 001 is Account in Salesforce...

Thanks,
Maharajan.C
JaySJayS 
<template>
   <lightning-card title="File" icon-name="standard : Files">
     <div class="slds‐m‐around_small">
      <template if:true={filesList}>
         <table class="slds-table slds-table_bordered slds-table_cell-buffer">
            <thead>
               <tr class="slds-text-title_caps">
                  <th scope="col">
                     <div title="Key">File Name</div>
                  </th>
                  <th scope="col">
                     <div title="Value">File Extension</div>
                  </th>
               </tr>
            </thead>
            <tbody>
               <template for:each={filesList} for:item="keyValue">
                  <tr key={keyValue.Id}>
                     <th scope="col">
                        <div>{keyValue.Title}</div>
                     </th>
                     <th scope="col">
                        <div>{keyValue.FileExtension}</div>
                     </th>
                  </tr>
               </template>
            </tbody>
         </table>
      </template>
      </div>
   </lightning-card>
</template>

import { LightningElement,api,wire } from 'lwc';
import queryFiles from '@salesforce/apex/filePreviewAndDownloadController.queryFiles'
export default class FileList extends LightningElement {
    @api recordId;
    wiredActivities;
    filesList =[];
    @wire(queryFiles, {recId: '$recordId'})
    wiredclass(value){
        this.wiredActivities = value;
        const { data, error } = value;
        if (data) {
            console.log(data)
            this.filesList = data;
            console.log('Data========> '+JSON.stringify(this.filesList));
        }
        if(error){
            console.log(error);
        }
    }
}
   

public with sharing class filePreviewAndDownloadController {
    @AuraEnabled(cacheable = true)
    public Static  List<ContentVersion> queryFiles(String recId){
        set<Id> SetIds = new Set<id>();
        list<Account> lstAccount = [Select Id,(Select Id From Contacts),(Select Id From Opportunities) from Account where Id = :recId];
        for(Account Acc : lstAccount){
            SetIds.add(Acc.Id);
            for(Contact con : Acc.Contacts){
            SetIds.add(con.Id);
            }
            for(Opportunity opp : Acc.Opportunities){
            SetIds.add(opp.Id);
            }
        }
           List<ContentDocumentLink> files = [SELECT ContentDocumentId FROM ContentDocumentLink WHERE LinkedEntityId = :SetIds];
            List<ID> fileIDs = new List<ID>();
            for (ContentDocumentLink docLink : files) {
                fileIDs.add(docLink.ContentDocumentId);
            }
            List<ContentVersion> docs = [SELECT Id,ContentDocumentId, FileExtension, Title
                                         FROM ContentVersion WHERE ContentDocumentId IN :fileIDs];
         
            return docs;
    }
}
 
Best Answer chosen by JayS
CharuDuttCharuDutt
Hii JayS
Try Below Code
<template>
    <lightning-card title="File Preview" icon-name="custom:custom11">
      <div class="slds‐m‐around_small">
       <template if:true={filesList}>
          <table class="slds-table slds-table_bordered slds-table_cell-buffer">
             <thead>
                <tr class="slds-text-title_caps">
                   <th scope="col">
                      <div title="Key">File Name</div>
                   </th>
                   <th scope="col">
                      <div title="Value">File Extension</div>
                   </th>
                </tr>
             </thead>
             <tbody>
                <template for:each={filesList} for:item="keyValue">
                   <tr key={keyValue.Id}>
                      <th scope="col">
                         <div>{keyValue.Title}</div>
                      </th>
                      <th scope="col">
                         <div>{keyValue.FileExtension}</div>
                      </th>
                      <th scope="col">
                         <lightning-button data-id={keyValue.ContentDocumentId}
                            access-key={keyValue.Title} 
                            icon-name="utility:preview"
                            label="Preview" 
                            variant="brand" 
                            value={keyValue.FileExtension}
                            onclick={filePreview}></lightning-button>
                      </th>
                   </tr>
                </template>
             </tbody>
          </table>
       </template>
       </div>
       <template if:true={ShowTable}>
          <div class="slds-box slds-theme_shade">
             <div class="slds-modal slds-fade-in-open slds-backdrop">
                <div class="slds-modal__container">
                   <!--HEADER Section-->  
                   <div class="slds-modal__header">
                      <lightning-button-icon icon-name="utility:close" alternative-text="Close this window" size="large"  
                         variant="bare-inverse" onclick={closeModal} class="slds-modal__close">  
                      </lightning-button-icon>
                      <h2>CSV File Details</h2>
                   </div>
                   <!---Body Section-->  
                   <div class="slds-modal__content slds-p-around_medium">
                      <table class="slds-table slds-table_bordered slds-table_cell-buffer">
                         <thead>
                            <tr class="slds-text-title_caps">
                               <template for:each={csvTableHeader} for:item="header">
                                  <th class="" scope="col" key={header}>
                                     <div class="slds-truncate" title={header}>{header}</div>
                                  </th>
                               </template>
                            </tr>
                         </thead>
                         <tbody>
                            <template for:each={lstCsvTableData} for:item="obj" for:index="Idx">
                               <tr class="slds-hint-parent" key={obj.rowIndx}>
                                  <template for:each={obj.data} for:item="Rec">
                                     <td key={Rec}>
                                        <div class="slds-truncate" title={Rec}>{Rec}</div>
                                     </td>
                                  </template>
                               </tr>
                            </template>
                         </tbody>
                      </table>
                   </div>
                   <!-- Section
                      <div class="slds-modal__footer">  
                        </div>
                      -->     
                </div>
             </div>
          </div>
       </template>
    </lightning-card>
 </template>


##############################################################################################################

JS


import { LightningElement,api,wire } from 'lwc';
import cvRecords2 from '@salesforce/apex/contenVersionFilePreview.cvRecords2'
import readCsvData from '@salesforce/apex/contenVersionFilePreview.readCsvData'
import {NavigationMixin} from 'lightning/navigation'
import {ShowToastEvent} from 'lightning/platformShowToastEvent';
import { refreshApex } from '@salesforce/apex';
import { deleteRecord } from 'lightning/uiRecordApi';
let lstCsvData = [];
let lstLowercaseHeader = [];
let lstNewTrimCsvData = [];
let lstAllCopyRecords = [];
let lstHeader = [];
export default class ContentVersionFilePreview extends  NavigationMixin(LightningElement) {
    @api recordId;
    csvTableHeader = [];  
    ShowTable = false;
    lstCsvTableData = [];
    dwnldVal;
    url;
    wiredActivities;
    ShowTable = false;
    filesList =[];

    closeModal(){
        this.ShowTable= false;
    }

    @wire(cvRecords2, {recId: '$recordId'})
    wiredclass(value){
        this.wiredActivities = value;
        const { data, error } = value;
        if (data) { 
            console.log(data)
            this.filesList = data;
            /*for(var i=0;i<data.length;i++){
                var h = '/sfc/servlet.shepherd/document/download/'+data[i].Id+'?operationContext=S1';

        
        this.url = encodeURI(h);
            }*/
            console.log('Data========> '+JSON.stringify(this.filesList));
        }
        if(error){ 
            console.log(error);
        } 
    }
 
    filePreview(event) {
       const fileName =event.target.accessKey;
	   const fileExten = event.target.value;
       const RecId = this.recordId;
       var mapOfCsv = new Map();
       this.lstCsvTableData = [];
       var convertCsvHeaderInLowrcase = [];
       var convertObjIntoPlainObj = [];
	   if(fileExten == 'csv'){
        readCsvData({recId: RecId,fileName:fileName})
        .then((result) => {
            var lstRows = result.split("\n");
                          var withoutBlankRow = [];
                          for(var i=0; i<lstRows.length; i++){
                              if(lstRows[i] != ''){
                                withoutBlankRow.push(lstRows[i]);
                              }
                          }
                        

                           var storeCsvHeader = withoutBlankRow[0].split(",");
                          let lstTrimHeader = [];
                          for(var i=0; i<storeCsvHeader.length; i++){
                              if(storeCsvHeader[i].trim() != ''){
                                  
                            lstTrimHeader.push(storeCsvHeader[i].trim());
                            convertCsvHeaderInLowrcase.push((storeCsvHeader[i].trim()).toLowerCase());
                          }
                        }
                          lstLowercaseHeader = convertCsvHeaderInLowrcase;
                       
                          this.ShowTable = true;
                          this.csvTableHeader = lstTrimHeader;
    
                             
                         lstCsvData = [];
                         console.log('withoutBlankRow : ' + JSON.stringify(withoutBlankRow));
                           for(var i=1; i< (withoutBlankRow.length); i++){
                               var lstEachRowData = withoutBlankRow[i].split(",");
                            console.log('lstEachRowData : ' + lstEachRowData);
                               let csvTrimData = [];
                               for(var j=0; j< lstTrimHeader.length; j++){
                                   csvTrimData.push(lstEachRowData[j].trim());
                                mapOfCsv.set(lstTrimHeader[j],lstEachRowData[j].trim());
                                
                              }
                              
                             let obj = Object.fromEntries(mapOfCsv.entries());
                            
                             convertObjIntoPlainObj.push(obj);
                            lstCsvData.push({ 'rowIndx' : i.toString(),
                                              'data' :csvTrimData,
                                              'isChecked' : false });
                              
                           }
                           lstNewTrimCsvData = convertObjIntoPlainObj;
                           
                           this.lstCsvTableData = lstCsvData;
           console.log('CSV=====> '+JSON.stringify(result));
        })
        .catch((error)=>{
            console.log('CSVE=====> '+error);
    });
       }else{
            this[NavigationMixin.Navigate]({
                type: 'standard__namedPage',
                attributes: {
                    pageName: 'filePreview'
                },
                state : {
                   
                    selectedRecordId:event.currentTarget.dataset.id
                }
              })
	   }
    }
}

#############################################################################################################

Apex


public class contenVersionFilePreview {
    @AuraEnabled(cacheable = true)
    public Static  List<ContentVersion> cvRecords2(String recId){
        set<Id> SetIds = new Set<id>();
        list<Account> lstAccount = [Select Id,(Select Id From Contacts),(Select Id From Opportunities) from Account where Id = :recId];
        for(Account Acc : lstAccount){
            SetIds.add(Acc.Id);
            for(Contact con : Acc.Contacts){
            SetIds.add(con.Id);
        	}
            for(Opportunity opp : Acc.Opportunities){
            SetIds.add(opp.Id);
        	}
        }
           List<ContentDocumentLink> files = [SELECT ContentDocumentId FROM ContentDocumentLink WHERE LinkedEntityId = :SetIds];
            List<ID> fileIDs = new List<ID>();
            for (ContentDocumentLink docLink : files) {
                fileIDs.add(docLink.ContentDocumentId);
            }
            List<ContentVersion> docs = [SELECT Id,ContentDocumentId, FileExtension, Title 
                						 FROM ContentVersion WHERE ContentDocumentId IN :fileIDs];
          
            return docs;// return [SELECT Id,ContentDocumentId, FileExtension,VersionData , Title FROM ContentVersion];
                						 
      
    }
}
Please Mark It As Best Answer If It Helps
Thank You!
Bogdan Andreev 2Bogdan Andreev 2 
How to create balance due? Maybe trigger?
I create visualforce page with table and fields from opportunity product. i need Balance due ( Sum of amount). How i can do this?
Screenshoot:
User-added image
my apex controller:
public class controllerTest {
    public Opportunity opportunity {get; set;}
    public List<OpportunityLineItem> oppLineItem {get; set;}
  	public OpportunityContactRole oppContactRole {get; set;}
  

    
    public controllerTest(){
        this.opportunity = [SELECT Id, Name, OwnerId, AccountId, Invoice_Number__c
                        FROM Opportunity
                        WHERE Id = 'X'
                       ];
        
        this.oppLineItem = [SELECT OpportunityId, Name, Quantity, UnitPrice, TotalPrice
                           FROM OpportunityLineItem
                           WHERE OpportunityId = 'X'                          
                          ];
        
        this.oppContactRole = [SELECT ContactId, OpportunityId, IsPrimary	
                           FROM OpportunityContactRole
                           WHERE OpportunityId = 'X'
                           AND IsPrimary = true
                          ];
    }
}

my vf page
<apex:page controller="controllerTest" applyHtmlTag="false" showHeader="false" renderAs="PDF">
    <html>
        <head>
        </head>
        <body>
            <div class="box--full">  
                <table style="font-family:sans-serif; padding-bottom:30px;">
                <tr>
                    <td><apex:image id="logo" value="{!$Resource.logo}" width="60" height="60"/></td>
                    <td style="font:8pt; padding-left:10px; padding-right:250px;">
                        {!$User.CompanyName }  <br/>
                        {!$User.Street } <br/>  
                        {!$User.FirstName}   
                        {!$User.LastName}  
                    </td> 
                    <td style="font:10pt;">INVOICE</td>
                    
                    
                </tr>
                
            </table>
                
                 <table style="border:0.5px solid #fff; font-family:sans-serif;">
                <tr>
                    
                    <td style="test-align:right; padding-right:20px;">Date</td> 
                    <td style="text-align:right;"><apex:outputText value="{!DAY(TODAY())}-{!MONTH(TODAY())}-{!YEAR(TODAY())}"/></td> 
                </tr>
                <tr>
                    
                    <td style="text-align:right; padding-right:20px;">Invoice #</td>
                    <td style="text-align:right;">[<apex:outputText value="{!opportunity.Invoice_Number__c}"/>]</td>
                </tr>
                
            </table>
            <div class="box--half">
                <h2 style="color:blue; font-size:14px;" class="heading heading--sub">Bill To:</h2>
                <apex:outputField value="{!oppContactRole.ContactId}"/>
                <apex:outputField value="{!oppContactRole.Contact}"/>
                <div>
                    
                </div>
            </div>
                
                <div class="box--full">
                
                <table>
                    <tr style="color:#fff; background-color:#ff4500;">
                        <th style="padding-left:5px; padding-right:380px;">PRODUCT NAME</th>
                        <th style="text-align:center; padding-left:5px; padding-right:5px;">QTY</th>
                        <th style="text-align:right; padding-left:15px; padding-right:5px;">UNIT PRICE</th>
                        <th style="text-align:right; padding-left:15px; padding-right:5px;">TOTAL</th>
                    </tr>
                
                
                     <apex:repeat value="{!oppLineItem}" var="OppLine">
                        <tr>
                            <td>{!OppLine.Name}</td>
                            <td>{!OppLine.Quantity}</td>
                            <td>{!OppLine.UnitPrice}</td>
                            <td>{!OppLine.TotalPrice}</td>
                        </tr>
                    </apex:repeat>
                  
                </table>
                </div>
            </div>
            <section>
                <footer>
                    <div>
                        {!$User.CompanyName }
                    </div>
                </footer>
            </section>
        </body>
    </html>
</apex:page>
how i get total price:
public List<OpportunityLineItem> oppLineItem {get; set;}

 this.oppLineItem = [SELECT OpportunityId, Name, Quantity, UnitPrice, TotalPrice
                           FROM OpportunityLineItem
                           WHERE OpportunityId = 'XXX'                          
                          ];

 <apex:repeat value="{!oppLineItem}" var="OppLine">
                            <tr style="background-color:#dcdcdc;">
                                <td>{!OppLine.Name}</td>
                                <td>{!OppLine.Quantity}</td>
                                <td>{!OppLine.UnitPrice}</td>
                                <td>{!OppLine.TotalPrice}</td>
                            </tr>
                            
                        </apex:repeat>
Total is list of opportunitylineitem im new in salesforce, can u say me how i can create trigger or formula or other... for balance due?

 
Best Answer chosen by Bogdan Andreev 2
Maharajan CMaharajan C
Hi Pogdan,

Update your class like below:
 
public class controllerTest {
    public Opportunity opportunity {get; set;}
    public List<OpportunityLineItem> oppLineItem {get; set;}
  	public OpportunityContactRole oppContactRole {get; set;}
	public decimal totalAmt {get; set;}
  
    public controllerTest(){
        this.opportunity = [SELECT Id, Name, OwnerId, AccountId, Invoice_Number__c
                        FROM Opportunity
                        WHERE Id = 'X'
                       ];
        
        this.oppLineItem = [SELECT OpportunityId, Name, Quantity, UnitPrice, TotalPrice
                           FROM OpportunityLineItem
                           WHERE OpportunityId = 'X'                          
                          ];
						  
		Decimal oliTotalAmount = 0;				  
		for(OpportunityLineItem oli : this.oppLineItem){
			oliTotalAmount += oli.TotalPrice;
		}
		this.totalAmt = oliTotalAmount;
		
        this.oppContactRole = [SELECT ContactId, OpportunityId, IsPrimary	
                           FROM OpportunityContactRole
                           WHERE OpportunityId = 'X'
                           AND IsPrimary = true
                          ];
    }
}

In the vf page directly refer this totalAmt property like {!totalAmt }. 

Thanks,
Maharajan.C
Salesforce NaelanSalesforce Naelan 
Hello, 

I am having a hard time with an error on two sandboxes org.

From Home, Opportunities and any other objects, i have a black cross on the background of the page and the following erreor when i scroll with my mouse. 
This error sometimes disappear by refreshing the navigator page but always come back. 
Does anione have an idea please ?

This page has an error. You might just need to refresh it. First, would you give us some details? (We're reporting this as error ID: 1568086648)
Technical stuff : 
[a.fromElement is undefined]
[79]</Ua.prototype.isEventFiredByShapeInsideTooltip()@https://naelan-software--presales.lightning.force.com/jslibrary/1642298026000/ui-analytics-reporting/EclairNG.js:999:346
[79]</Ua.prototype._onMouseLeave()@https://naelan-software--presales.lightning.force.com/jslibrary/1642298026000/ui-analytics-reporting/EclairNG.js:998:172

User-added image
Best Answer chosen by Salesforce Naelan
Sai PraveenSai Praveen (Salesforce Developers) 
Hi Neelam,

Can you confirm if this is happening only in particular browsers? Generally this errors occurs if the browsers does not support the js file. 

Thanks,