• Atosi Malakar
  • NEWBIE
  • 0 Points
  • Member since 2023

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 9
    Replies
HI Everyone,

I have written the below code :
 
Can you write map instead of a list  . Instead of two for loops pass maps:
 
public class HelperAccount{
    public static void helpaccmethod(List<account> oldAccount, List<account> newAccount){
        List<contact> conList=[select lastname,otherphone,accountid,phone from contact 
                               where accountid IN: newAccount];
        map<id,string> oldAccidVsPhone= new map<id,string>();
        map<id,string> newAccidVsPhone= new map<id,string>();
        for(account newAcc: newAccount){
            for(account oldAcc: oldAccount){
                if(newAcc.phone!=oldAcc.phone && oldAcc.id==newAcc.id){
                    oldAccidVsPhone.put(oldAcc.id,oldAcc.phone);
                    newAccidVsPhone.put(newAcc.id,newAcc.phone);
                }
            }
        }
        list<contact> updateContactList= new List<contact>();
for(contact con: conList){
            if(oldAccidVsPhone.containskey(con.accountid)){
                con.phone=oldAccidVsPhone.get(con.accountid);
                con.Phone=newAccidVsPhone.get(con.accountid);
                updateContactList.add(con);
            }
        }
        if(updateContactList.size()>0){
            update updateContactList;
        }
    }
}
 
Trigger:
 
trigger UpdateAccount on Account (before update,after update) {
    if(trigger.isUpdate && trigger.isBefore){
        HelperAccount.helpaccmethod(trigger.old,trigger.new);
    }
}
I have a flow that updates a field (using a function created in Apex) and performs an action to send email.
When I load more than 1 record (with the DataLoader) it generates an error:
 
Se ha producido un error: El número de resultados no coincide con el número de entrevistas que se han ejecutado en una única solicitud de ejecución masiva.
Flow Error: Number of results do not match the number of interviews that have been carried out in a single execution request.
 
Only occurs with load of 2 or + records. 
If with Data Loader I load only 1 record it works correctly.
Some idea about this problem?
Thanks
User-added image
Inside the console it giving me an error like-->{status: 400, body: {…}, headers: {…}, ok: false, statusText: 'Bad Request', …}
body: {message: 'An error occurred while trying to update the record. Please try again.', statusCode: 400, enhancedErrorType: 'RecordError', output: {…}}
errorType: "fetchResponse"
headers: {}
ok: false
status: 400
statusText: "Bad Request"
[[Prototype]]: Object

And Here is my code-->can Some one please let me know where the problem and How I can create the Account  record.
Please Response with the soloution.
.html code
<template>
    <!-- Form this we have created the Account record form, -->
    <!-- but,Now as soon as the record the user will be inserted should be save -->
      <lightning-layout>
         <lightning-layout-item size="12">
               <lightning-card  title="AccountRecordForm">
                    <lightning-input type="text"  label="Name" onchange={handleName}>
                    </lightning-input>
                    <lightning-input type="text" label="Phone" onchange={handlePhone}>
                    </lightning-input>
                    <lightning-button  label="Save" onclick={handleSave}>  
                           
                    </lightning-button>
               </lightning-card>
         </lightning-layout-item>
      </lightning-layout>
</template>
.js
import { LightningElement,api } from 'lwc';
import { createRecord } from 'lightning/uiRecordApi';
export default class LDSFormMaking1 extends LightningElement {
    //Declare the variable
    Name;
    Phone;
    //Now I want to store the data which user will be inserted into the
    //Account Name-Rahul ,Phone-->784578455 As well as for the Save button
    //So that Record should be save
    //Now first I want to fetch the data of the User who is inserting the data
    //in the Name text box i.eName-->Rahul(I want to store the Rahul inside the Name)
    //So for that make the handleName inside the html.
    handleName(event)
    {
         //For the Name ,when the user will inserted any data
         //will be inside the Name text box
         //1)--> User will insert the data inside the Name
             //soon ,the user will be hitting the event
         //2)--> That,insert value will be inside the event
        this.Name=event.target.value;  //From this, the user value will be inside the Name
    }
    handlePhone(event)
    {
         this.Phone=event.target.value; //From this, the User value phone will be inside the Phone
    }
    handleSave()
    {
          //Now Inside the Save button ,When ever the user will
          //Inserting the value like the Name and Phone
          //Should be Save the Record into the Salesforce Org.
          //1)To Create the Record -->Fetch Create Record from the Lightning/uiRecordApi.
          //Now How to create the object let see,Hit on lightning/uiRecordApi
          //To create Record
          //I need to fetch first Fields for that
          let fields={'Name':this.Name,'Phone':this.Phone};
          //Now I want to fetch whole Record so for that,
          let Record={'apiName':'Account','Fields':fields};
          //Now I want to send the record
          //createRecord(Record); //From this you can send the record
                                //Which you have created.
          //But when the user will inserted any record or not
          //For that ,using the then Method for this
          createRecord(Record).then(x=>{
               //If the Record has been created it will print the value
               console.log(x);  
          }).catch(err=>{
              console.log(err);  //Else it will catch the error
          })          
    }
}
.metadeta file
<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
    <apiVersion>57.0</apiVersion>
    <isExposed>true</isExposed>
    <targets>
        <target>lightning__AppPage</target>
        <target>lightning__HomePage</target>
        <target>lightning__RecordPage</target>
        <target>lightning__Tab</target>
    </targets>
</LightningComponentBundle>
When configuring the button menu in lwc using a custom icon, it still shows the down icon beside the icon I kept. Would anyone be able to help on that how to remove attaching a screenshot for reference? below is the code I used.
<lightning-button-menu  icon-name="utility:threedots"  variant="border" size="xx-small" title="More actions" onselect={handleOnselect} class="slds-m-left_xx-large" >
             <lightning-menu-item value="Test" label="Test"></lightning-menu-item>
                                        <lightning-menu-item value="Test1" label="Test1"></lightning-menu-item>
                                    
  </lightning-button-menu>
User-added image
If anyone worked on the below use case, please reply back.

Use Case: On the Contract page, after saving the data, when I click on a button, a document print will be generated. A file attachment (docs or pdf) against that record should also get printed on a running page.
I'm migrating an org from Classic to Lightning Experience, where the Detail page currently has a button that opens a Visualforce page (rendered as a PDF, e.g. /apex/myPdf?id={record.Id}) in a new window

In Lightning Experience, the detail page button will open the URL in the same window (despite behaviour being set to Display in new window). The only solution I've found so far would be to use a Lightning Component as an Action, and in the init method, open a new window. This part is fine, but then if the user returns to the original window (record page), they will see the modal still open.

From what I've read so far, if I want to auto-close the modal (i.e. $A.get("e.force:closeQuickAction").fire()) I cannot do that in the init method, so I would have to call this asynchronously (e.g. https://salesforce.stackexchange.com/questions/189248/forceclosequickaction-not-working ).

Is this really the only way to accomplish this? It seems like an overly complicated implementation to do something which seems very trivial (open a new window).

Is there any way to get the profile name of logged in user without querying the user object.

 

I know the following solution:

 

String usrProfileName = [select u.Profile.Name from User u where u.id = :Userinfo.getUserId()].Profile.Name;

 

Instead of this I want to save 1 query so if there is any method to get the profile name in apex without firing the query please let me know.

 

Thanks,