• Ashvin J
  • NEWBIE
  • 85 Points
  • Member since 2021

  • Chatter
    Feed
  • 3
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 15
    Replies
Hi
document obj contains a csv file
it should be read by batch apex and records shoud be inserted into an object
controller:-

({
    doInit : function(component, event, helper) {
           // create a one-time use instance of the serverEcho action
        // in the server-side controller
        var action = component.get("c.getcontact");
        action.setParams({ accountId : component.get('v.recordId'), });
 
        // Create a callback that is executed after 
        // the server-side action returns
        action.setCallback(this, function(response) {
            var state = response.getState();
            if (state === "SUCCESS") {
                // Alert the user with the value returned 
                // from the server
                component.set("v.contactname",response.getReturnValue());
                 console.log(response.getReturnValue());
                // You would typically fire a event here to trigger 
                // client-side notification that the server-side 
                // action is complete
            }
            else if (state === "INCOMPLETE") {
                // do something
            }
            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");
                }
            }
        });
 
        // optionally set storable, abortable, background flag here
 
        // A client-side action could cause multiple events, 
        // which could trigger other events and 
        // other server-side action calls.
        // $A.enqueueAction adds the server-side action to the queue.
        $A.enqueueAction(action);
    },
    
     doButton : function(component, event, helper) {
        var eventSource = event.getSource();
        var id = eventSource.get(v.name);
        alert(id); 
    }
});

Aura Component:

<aura:component controller="contactclass" implements="flexipage:availableForAllPageTypes,force:hasRecordId">
    
    <aura:attribute name="contactname" type="Contact[]" />
    <aura:handler name="init" value="{!this}" action="{!c.doInit}" />
    
    {!v.recordId}
    <div class="slds-grid slds-wrap">
        <aura:iteration items="{!v.contactname}" var="item" >
              <div class="slds-col slds-size_1-of-3">
                  <div class="slds-p-around_x-small">
                <lightning:card footer="Business Card" title="Cognizant" variant="Narrow"  iconName="standard:employee_asset">
                    <aura:set attribute="actions">
                    
                        <lightning:button variant="brand" name="values"  label="More" title="Brand action" onclick="{!c.doButton }" />                  
                    </aura:set>
                        <p class="slds-p-horizontal_small">
                             {!item.FirstName} &nbsp; {!item.LastName}<br />
                            </p>
                   </lightning:card>
              </div>        
            </div>             
        </aura:iteration>
     
    </div>    
    
</aura:component>

contact class:-
I have a custom field, Field A. This field should be populated with one of 3 values based on the combination of 3 other fields Field 1, Field 2 and Field 3. 

There are 44 different possible combinations of Fields 1, 2 and 3 so making Field A a formula field is not possible due to character limits. 

I have tried to make a concatenation formula field of fields 1, 2 and 3 however still can have 44 possible concatenations and do not know of a good way to use this field to populate Field A. 

Can anyone suggest what I might do here? 
Hello everyone,

I have created a visualforce Email template that uses a visualforce component to display some records in a form of a table. The problem is that inside my visualforce component whatever HTML I use, it does not render the HTML and in Email preview, it shows  the HTML tags. For example I want to create a simple table  isnide my component :

Email Template :
<messaging:emailTemplate subject="test subject" recipientType="Contact" relatedToType="Booking__c">
<messaging:plainTextEmailBody >

<c:PaxInformation/>

Congratulations!
This is your new Visualforce Email Template.

Dear Partner,  
blah blah blah.......

</messaging:plainTextEmailBody>
</messaging:emailTemplate>

Visualforce Component (Name : PaxInformation)

<apex:component controller = "PaxInformationController" access="global" >

<table class="table">
    <thead>    
        <tr>
            <th>Opportunity Name</th> 
            <th>Opportunity Description</th>
            <th>Opportunity Amount</th>
        </tr>
    </thead>        
</table>
</apex:component>


Final Email received (body): 


User-added image


____________________________________

Any ideas on why is this happening?
Why it does not render the html tags to an actual html table?


Thanks in advance,
Michael.
my code
 @HttpPut
     global static Id upsertUser(String Firstname,String Lastname,  String alias,String ProfileId,String Email,
                                String   TimeZoneSidKey,String LanguageLocaleKey,
                               String EmailEncodingKey,String LocaleSidKey,String UserName)
   {
      
           User updateUser = new  User();
        updateUser.Firstname = firstname;
        updateUser.Lastname = lastname;
        updateUser.Email = email;
        updateUser.Alias = alias;
        updateUser.Username = username;
        updateUser.ProfileId = ProfileId ;
        updateUser.TimeZoneSidKey = TimeZoneSidKey;
        updateUser.LanguageLocaleKey = LanguageLocaleKey;
        updateUser.EmailEncodingKey = EmailEncodingKey;
        updateUser.LocaleSidKey = LocaleSidKey;
        upsert updateUser; 
           
        return updateUser.Id;                                
        
    }      
    
Hi
document obj contains a csv file
it should be read by batch apex and records shoud be inserted into an object
controller:-

({
    doInit : function(component, event, helper) {
           // create a one-time use instance of the serverEcho action
        // in the server-side controller
        var action = component.get("c.getcontact");
        action.setParams({ accountId : component.get('v.recordId'), });
 
        // Create a callback that is executed after 
        // the server-side action returns
        action.setCallback(this, function(response) {
            var state = response.getState();
            if (state === "SUCCESS") {
                // Alert the user with the value returned 
                // from the server
                component.set("v.contactname",response.getReturnValue());
                 console.log(response.getReturnValue());
                // You would typically fire a event here to trigger 
                // client-side notification that the server-side 
                // action is complete
            }
            else if (state === "INCOMPLETE") {
                // do something
            }
            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");
                }
            }
        });
 
        // optionally set storable, abortable, background flag here
 
        // A client-side action could cause multiple events, 
        // which could trigger other events and 
        // other server-side action calls.
        // $A.enqueueAction adds the server-side action to the queue.
        $A.enqueueAction(action);
    },
    
     doButton : function(component, event, helper) {
        var eventSource = event.getSource();
        var id = eventSource.get(v.name);
        alert(id); 
    }
});

Aura Component:

<aura:component controller="contactclass" implements="flexipage:availableForAllPageTypes,force:hasRecordId">
    
    <aura:attribute name="contactname" type="Contact[]" />
    <aura:handler name="init" value="{!this}" action="{!c.doInit}" />
    
    {!v.recordId}
    <div class="slds-grid slds-wrap">
        <aura:iteration items="{!v.contactname}" var="item" >
              <div class="slds-col slds-size_1-of-3">
                  <div class="slds-p-around_x-small">
                <lightning:card footer="Business Card" title="Cognizant" variant="Narrow"  iconName="standard:employee_asset">
                    <aura:set attribute="actions">
                    
                        <lightning:button variant="brand" name="values"  label="More" title="Brand action" onclick="{!c.doButton }" />                  
                    </aura:set>
                        <p class="slds-p-horizontal_small">
                             {!item.FirstName} &nbsp; {!item.LastName}<br />
                            </p>
                   </lightning:card>
              </div>        
            </div>             
        </aura:iteration>
     
    </div>    
    
</aura:component>

contact class:-
Hi All,
I have a countofCEO__c field on the Account Object and Account has couple of Opportunties with Title__c field .After an opp is updated and Title__c field which had some value ealier is left blank the the field countofCEO__c field  on the account object should subtract 1 from it and update account Object.....The below given code is working fine then I update an opp from the user interface and leave Title__c field blank then 1 is subttracted  the field on the Account object .

However,when I try to do same thing from the Data loader the program is not working as desired.

The below given line is the culprit.When I remove Opp.title__c and only keep  the line "if(opp.title__c!=trigger.oldmap.get(opp.Id).title__c)
and try to update couple of opp's through the data loader then it works fine.If I add if(opp.title__c==null) in addition to th above line then it does not work....I need to check for the Value in the Title__c field so if its null then then I need to update account object..

So what is wrong with the null value line when trying to update opps through Data Loader.?
   

       if(opp.title__c==null && opp.title__c!=trigger.oldmap.get(opp.Id).title__c)
       {



Trigger CountOfOppwithCEOTitle on Opportunity (After Update)
{
   Set<id>Accids=new set<id>();
   Map<id,opportunity>mapofOppIdtoOppRecords=new map<id,opportunity>();
   for(opportunity opp:trigger.new)
   {
       if(opp.title__c==null && opp.title__c!=trigger.oldmap.get(opp.Id).title__c)
       {
           
           
           system.debug('I am in the initial for loop');
           mapofOppIdtoOppRecords.put(opp.id,opp);
           Accids.add(opp.accountid);
           
           
       }
   
   }
   
Map<id,Account>MapofAccountIdToAccount=new map<id,account>([select id,countofCEO__c from account where id in:Accids]);    
List<opportunity>Opp=[Select id,title__c,Accountid from Opportunity where id in:mapofOppIdtoOppRecords.keyset()];
//select id,countofCEO__c,from account
//where id in:mapofAccIdtoOppRecords.keyset()];
list<account>acclist=new list<account>();  
for(Opportunity Opprecords:opp)
{
  system.debug('I am in for loop');
if(MapofAccountIdToAccount.containskey(opprecords.accountid)&& Opprecords.title__c==null)
  {
      
        system.debug('The debug value is');
   
        Account Acc=MapofAccountIdToAccount.get(Opprecords.Accountid);
        Acc.countofCEO__c=acc.countofCEO__c-1;
        acclist.add(acc);
      
      
  }
}
    try
    {
        
        if(!acclist.isEmpty()&& acclist.size()>0)
        {
            
            Map<id,Account>MapofAccountIdToOpp=new map<id,account>();
            MapofAccountIdToOpp.putall(acclist);
            update MapofAccountIdToOpp.values();
        }
    }
    catch(DmlException de)
    {
        
    }
    
}
I would like to find out a way for the system to determine that the lead (which is newly created) is already part of an open opportunity, and that the lead record should be then assigned to the same sales rep that owns the opportunity
When I try to Query 
Invoice__C[] InvoiceData =  [Select Id,Attachment_Id__c,Supporting_Attachment_Id__c from Invoice__c where Id=:InvoiceId]; 
In the debug I see Only Id and Attachment_Id__c fields, because Supporting_Attachment_Id__c is null.
But then I try to  check it using below line.
if(InvoiceData[0].Supporting_Attachment_Id__c == ''||InvoiceData[0].Supporting_Attachment_Id__c == null)
It throws System.NullPointerException: Attempt to de-reference a null object.

How to solve this issue?
Hi - Need help on creating custom related list using Lightning web components for an object in details tab section. Example as below and the notes button has been created already and need to use in this new component. can someone help on this. Thanks! 
User-added image
I have a custom field, Field A. This field should be populated with one of 3 values based on the combination of 3 other fields Field 1, Field 2 and Field 3. 

There are 44 different possible combinations of Fields 1, 2 and 3 so making Field A a formula field is not possible due to character limits. 

I have tried to make a concatenation formula field of fields 1, 2 and 3 however still can have 44 possible concatenations and do not know of a good way to use this field to populate Field A. 

Can anyone suggest what I might do here? 
Hello,
I work in a company that our salesforce platform's architect follows SalesForce's trigger best practice to have a recursion check on Opportunity to stop the execution on each event independently. So the ExecuteAfterUpdate will run exactly once for each opportunity record. 
Here is my requirement:
1.  Apex class to have an API call to import Opportunity and OpportunityLineItems from another systme to Salesforce
2. Rollup OpportunityLineItems value to corresponding Opportunity value
3. Calculate OpportunityLineItems' value percentage= OpportunityLineItem Value/ Opportunity value.
Here is the implementation:
1. Apex class1 insert/update Opportunities
2. Opportunity Trigger is executed 1st time
3. Same Apex class1 then insert/update OpportunityLineItems
4. OpportunityLineItem trigger is exeucted 1st time and calls Apex class2 to rollup OpportunityLineItems value to Opportunity value, Opportunity is updated
5. Opportunity trigger is executed 2nd time and calls Apex class3 to calculate OpportunityLineItems' value percentage= OpportunityLineItem Value/ Opportunity value.
I am blocked in step#5, because Opportunity trigger is executed 2nd time, our company's trigger recusion check finds this Opportunity is already processed in step#2, it does not pass this Opportunity record to Apex class3.
My questions:
1. Is my implementation correct? 
2. Is company's trigger recursion implementation correct, because the same Opportunity record's value in step #2 and step #5 is not the same?
3. What should I do to bypass it?

thank you for the help.
Lei