• SULEMAN ZIA
  • NEWBIE
  • 10 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 2
    Replies
Is there a way to embed a regular dashboard in our custom lightning component ?

As of now the only way to add dashboard is to create a new lighting app and drag the dashboard component to the widget and then manually select the dashboard which we want to display on the lightning app. 

I want to add the same dashboard by using the dashboard id in my custom lightning component. You can't use iframe because the dashboard exist in same domain and hence we get 'same-origin policy' error. Any ideas ?. 
Original question:
I have overriden my standard newContact page with a custom lightning component bundle. The reason i did this is to avoid  standard salesforce fields like account phone getting auto populated when creating a contact through Account related list. 

I utilized force:createRecord event and have resolved almost all of the issues except for only 1 which i am stuck and need to get it resolved.

Problem: The problem is that in my component i am retrieveing accountId and recordTypeID. When i click on an account i ended up on the detail page. Now when i click new contact from account detail related list, it invokes my lightning component which basically fires force:Createrecord event. Since i came from the account detail page, my parent window should be account detail page also but it is not. It basically hovers over to an empty 'Contacts'  tab. This is because the window URL has changed.

Original URL before creating new contact from account detail page:-
https://*.force.com/one/one.app#/sObject/001f400000AdMNOAA3/view

After clicking new contact :-
https://*.force.com/one/one.app#/sObject/Contact/new?recordTypeId=012f4000000DzRj&additionalParams=accid%3D001f400000AdMNO%26

My question is that is there any way i can take the user back to account detail page if he/she closes the modal dialog or click cancel ? or can i capture that event so i can invoke some JS function to redirect user to the correct page ? Please find my small test code below

ContactComponent.cmp
<aura:component implements="force:lightningQuickAction,lightning:actionOverride,force:hasRecordId,flexipage:availableForAllPageTypes,force:appHostable" access="global">
    <aura:handler name="init" value="{!this}" action="{!c.init}" />
    <aura:attribute name="accid" type="Id" />
    <aura:attribute name="recordTypeId" type="Id" />
</aura:component>

ContactComponentController.js
({
    init : function(component, event, helper) {
        console.log('insideinit');
                var createAcountContactEvent = $A.get("e.force:createRecord");
                console.log('Account ID after action is ' + accId);
                createAcountContactEvent.setParams({
                    "entityApiName": "Contact",
                    "defaultFieldValues": {
                        'Phone' : ''
                    }
                });
                createAcountContactEvent.fire(); 
    }
}) 
Hello awesome devs! 

Need some help here as I am at a loss why the following Trigger is not setting values on all records but it setting a value on some of the records when doing a mass insert r or update.  When you go to a single record and perform an update the trigger always fires correctly.  

What is trying to be achieved:  

When a record on Object A is created or updated and it includes a SKU in a field called SKU__c .
Then trigger is called on Object A to find a Product from our standard Product2 object that have the same value in the ProductCode field as the SKU__c fiel don Object A.  
When found, a field (Product_Line__c) on Object A should be populated with the value form the found Product2 record and its Product_Line__c field. 

Again this works when updating records one by one, but anythign in mass, will only update a few records.  (Latest example: out of 1097 records in a mass update, only roughly 40 records got updated, the rest have nothign populated in the Product_Line__c field on Object A.

Can anyone look over my code, and help me out? :)

Thank you so much all,

Shawn

Trigger Code:
 
trigger PopulateProductLineOnCharge on Zuora__SubscriptionProductCharge__c (before insert, before update) {

    
    List<Zuora__SubscriptionProductCharge__c> spcToUpdate = new List<Zuora__SubscriptionProductCharge__c>();
    String pLineText = '';
    String SkuText = '';
    Product2 P;
    
    
    For(Zuora__SubscriptionProductCharge__c s : Trigger.new){
        If(s.Product_Line__c == null && s.SKU__c != null){
            SkuText = s.SKU__c;
        }
    }
    
    If(SkuText != null){
    P = [SELECT Id, Product_Line__c, ProductCode FROM Product2 WHERE ProductCode = : SkuText LIMIT 1];
    
    For(Zuora__SubscriptionProductCharge__c s2 : Trigger.New){
        If(SkuText.contains(s2.SKU__c)){
            s2.Product_Line__c = p.Product_Line__c;
            spcToUpdate.add(s2);
        }
        }
    }
 
}

 
Original question:
I have overriden my standard newContact page with a custom lightning component bundle. The reason i did this is to avoid  standard salesforce fields like account phone getting auto populated when creating a contact through Account related list. 

I utilized force:createRecord event and have resolved almost all of the issues except for only 1 which i am stuck and need to get it resolved.

Problem: The problem is that in my component i am retrieveing accountId and recordTypeID. When i click on an account i ended up on the detail page. Now when i click new contact from account detail related list, it invokes my lightning component which basically fires force:Createrecord event. Since i came from the account detail page, my parent window should be account detail page also but it is not. It basically hovers over to an empty 'Contacts'  tab. This is because the window URL has changed.

Original URL before creating new contact from account detail page:-
https://*.force.com/one/one.app#/sObject/001f400000AdMNOAA3/view

After clicking new contact :-
https://*.force.com/one/one.app#/sObject/Contact/new?recordTypeId=012f4000000DzRj&additionalParams=accid%3D001f400000AdMNO%26

My question is that is there any way i can take the user back to account detail page if he/she closes the modal dialog or click cancel ? or can i capture that event so i can invoke some JS function to redirect user to the correct page ? Please find my small test code below

ContactComponent.cmp
<aura:component implements="force:lightningQuickAction,lightning:actionOverride,force:hasRecordId,flexipage:availableForAllPageTypes,force:appHostable" access="global">
    <aura:handler name="init" value="{!this}" action="{!c.init}" />
    <aura:attribute name="accid" type="Id" />
    <aura:attribute name="recordTypeId" type="Id" />
</aura:component>

ContactComponentController.js
({
    init : function(component, event, helper) {
        console.log('insideinit');
                var createAcountContactEvent = $A.get("e.force:createRecord");
                console.log('Account ID after action is ' + accId);
                createAcountContactEvent.setParams({
                    "entityApiName": "Contact",
                    "defaultFieldValues": {
                        'Phone' : ''
                    }
                });
                createAcountContactEvent.fire(); 
    }
})