• Haider Naseem
  • NEWBIE
  • 20 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 2
    Replies
Hi Team,

I have a scenario where I will be over-riding the standard edit and view buttons on opportunity with the same lightning component.
Within this component, I need to identify whether Edit or View was clicked based on which I will display further UI.

I am stuck at this point as I am unable to find a way to check which standard button was clicked. Is it possible to identify the same? If yes how?

Regards,
Haider Naseem
Hi All,

I am working in a classic to lightning migration scenario.

In classic, we have a detail page button (Content Source: URL) that opens up a visualforce page.

In lightning, I created a lightning component similar to the visualforce page. Then I created a detail page button (Content Source: URL) to launch the standard lightning component tab. This Lightning component tab does open my lightning component but does not run Init(). 

Could you please suggest me the best approach to go about this type of migration? Also, how to fix the problem where init() is not called on opening the Lightning Component Tab?

Your suggestions are much appreciated.

Regards,
Haider
Hi All,
In lightning experience service cloud console app, I have a list button in the related list. I need to open a new lightning component in a subtab in the console on click of this button.

I am unable to figure  out how this can be achieved. Please suggest.

Thanks in advance!
Hi,

I have the following trigger:
trigger conCreateFromAccount on Account (after insert) {
  List<Contact> conList = new List<Contact>();
      for (Account newAccount: Trigger.New) {

           Contact con = new Contact();
           con.lastname = newAccount.name + '  - Contact';
           con.Accountid = newAccount.id;
           conList.add(con);
          }
          
    insert conList;
    list<account>acctsUp = new list<account>();
    for(contact e: conList){

         account a = new account(Id = e.AccountId);
         a.Contact_ID__c = e.Id;
         acctsUp.add(a);
      }

      update acctsUp;
}

From what I know, records in AFTER are read-only and cannot be updated. However, I am able to update the account record in the after insert trigger without any issue. Theoretically I should be receiving the Read Only error, but I am not. Why?
 
Hi,

I get the below error when executing the trigger for the challenge:

Challenge Not yet complete... here's what's wrong: 
There was an unexpected error in your org which is preventing this assessment check from completing: System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, DynastyRoot: execution of BeforeInsert caused by: System.NullPointerException: Attempt to de-reference a null object Trigger.DynastyRoot: line 8, column 1: []

The challenge is:To complete this challenge, you need to add a trigger for Opportunity. The trigger will add a task to any opportunity inserted or updated with the stage of 'Closed Won'. The task's subject must be 'Follow Up Test Task'.
The Apex trigger must be called 'ClosedOpportunityTrigger'
With 'ClosedOpportunityTrigger' active, if an opportunity is inserted or updated with a stage of 'Closed Won', it will have a task created with the subject 'Follow Up Test Task'.
To associate the task with the opportunity, fill the 'WhatId' field with the opportunity ID.
This challenge specifically tests 200 records in one operation.


Code:

trigger ClosedOpportunityTrigger on Opportunity (after insert, after update) {

    List<Task> taskList = new List<Task>();
    
    for(Opportunity opp : Trigger.new) {
        
        //Only create Follow Up Task only once when Opp StageName is to 'Closed Won' on Create
        if(Trigger.isInsert) {
            if(Opp.StageName == 'Closed Won') {
                taskList.add(new Task(Subject = 'Follow Up Test Task', WhatId = opp.Id));
            }
        }
        
        //Only create Follow Up Task only once when Opp StageName changed to 'Closed Won' on Update
        if(Trigger.isUpdate) {
            if(Opp.StageName == 'Closed Won' 
            && Opp.StageName != Trigger.oldMap.get(opp.Id).StageName) {
                taskList.add(new Task(Subject = 'Follow Up Test Task', WhatId = opp.Id));
            }
        }       
    }

    if(taskList.size()>0) {        
        insert taskList;        
    }    
}

 

<table class="slds-table slds-table_cell-buffer slds-table_bordered">
            <thead>
                <tr class="slds-line-height_reset slds-border--bottom">
                    <th class="" scope="col"><ui:inputCheckbox/></th>
                    <th class="" scope="col">
                         <div class="slds-truncate " title="Name">Name</div>
                    </th>
                    <th class="" scope="col">
                         <div class="slds-truncate" title="Name">Industry</div>
                    </th>
                    <th class="" scope="col">
                         <div class="slds-truncate" title="Name">Phone</div>
                    </th>
                    <th class="" scope="col">
                         <div class="slds-truncate" title="Name">Rating</div>
                    </th>
                </tr>
            </thead>
            <aura:iteration items="{!v.accounts}" var="ac">
                <tr class="slds-hint-parent">
                    <td class="slds-truncate"><ui:inputCheckbox aura:id="checkbox" change="{!c.handleCheckbox}"/></td>
                    <td class="slds-truncate">{!ac.Name}</td>
                    <td class="slds-truncate">{!ac.Industry}</td>
                    <td class="slds-truncate">{!ac.Phone}</td>
                    <td class="slds-truncate">{!ac.Rating}</td>
                </tr>
            </aura:iteration>
        </table>

output:

User-added image


Expected output:
User-added image

Thanks&Regards
Mahesh

 
  • April 11, 2019
  • Like
  • 0
Hi,

I get the below error when executing the trigger for the challenge:

Challenge Not yet complete... here's what's wrong: 
There was an unexpected error in your org which is preventing this assessment check from completing: System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, DynastyRoot: execution of BeforeInsert caused by: System.NullPointerException: Attempt to de-reference a null object Trigger.DynastyRoot: line 8, column 1: []

The challenge is:To complete this challenge, you need to add a trigger for Opportunity. The trigger will add a task to any opportunity inserted or updated with the stage of 'Closed Won'. The task's subject must be 'Follow Up Test Task'.
The Apex trigger must be called 'ClosedOpportunityTrigger'
With 'ClosedOpportunityTrigger' active, if an opportunity is inserted or updated with a stage of 'Closed Won', it will have a task created with the subject 'Follow Up Test Task'.
To associate the task with the opportunity, fill the 'WhatId' field with the opportunity ID.
This challenge specifically tests 200 records in one operation.


Code:

trigger ClosedOpportunityTrigger on Opportunity (after insert, after update) {

    List<Task> taskList = new List<Task>();
    
    for(Opportunity opp : Trigger.new) {
        
        //Only create Follow Up Task only once when Opp StageName is to 'Closed Won' on Create
        if(Trigger.isInsert) {
            if(Opp.StageName == 'Closed Won') {
                taskList.add(new Task(Subject = 'Follow Up Test Task', WhatId = opp.Id));
            }
        }
        
        //Only create Follow Up Task only once when Opp StageName changed to 'Closed Won' on Update
        if(Trigger.isUpdate) {
            if(Opp.StageName == 'Closed Won' 
            && Opp.StageName != Trigger.oldMap.get(opp.Id).StageName) {
                taskList.add(new Task(Subject = 'Follow Up Test Task', WhatId = opp.Id));
            }
        }       
    }

    if(taskList.size()>0) {        
        insert taskList;        
    }    
}