• Sumesh Chandran
  • NEWBIE
  • 60 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 12
    Questions
  • 10
    Replies
I am trying to use the DML statement to make an insert to the parent and child tables all at once.

I have got it to this point so far, I am not sure how to link the child to the parent when doing the insert in one command.

I tried following the instructions on the post below, got a bit confused. On the code there they use an external ID to make it happen which I am not sure about as I want the child objects to have the id of the parent record on its foreign key relationship field. I already have a master-detail relationship setup between the custom objects.

https://salesforce.stackexchange.com/questions/133906/insert-list-of-parent-and-child-records-in-one-dml-statement][1]

Here is what I go to so far. How do I link the 2 objects using the master-detail relationship setup and how to use the insert statement.
 
List<addressMaster__c> mduMaster = new List<addressMaster__c>();
            List<addressDetail__c> mduDetails = new List<addressDetail__c>();         
            Object[] values = (Object[])System.JSON.deserializeUntyped(mdus);
            for( Object mdu : values) {
                Map<String,Object> data = (Map<String,Object>)mdu;
                streetAddress = String.valueof(data.get('streetAddress'));
                totalUnits = Integer.valueof(data.get('totalUnits'));
                nnUnits = Integer.valueof(data.get('nnUnits'));            
                addressDetail__c newMduDetail = new addressDetail__c(Name=streetAddress,nnUnits__c=nnUnits,lastReportDate__c=DateTime.now());                                                         
                addressMaster__c newMduMaster = new addressMaster__c(Name=streetAddress,totalUnits__c=totalUnits);
                    
                mduDetails.add(newMduDetail);
                mduMaster.add(newMduMaster);
            }
Please advise!
 
How do i add a space in between the sup.name & sup.count and also how do I change the font color of the sup.count part

<aura:set attribute="label">
   {!sup.name} <b style="color:red">({!sup.count})</b>
 </aura:set>

This simple doesn't work at all.

 
I am trying to create a multidimensional array and want the items of that array to be iterated using Aura Iteration. In the below code at the end I want array in a key value pair format like {name:"", count:''} and want that array to be iterated through in the component markup. This is where I was able to get to so far. Please advise!
var sups = [];
 var supOpps = [,];
           for (var i = 0; i < result.length; i++) {                     
                    sups.push(result[i].sumchans__Owner_Manager__c);                     
                }
                sups = Array.from(new Set(sups));
                for (var i = 0; i < sups.length; i++) {                     
					supOpps[i,i] == sups[i];
                    supOpps[i,i+1] == result.filter(x => { 
                        return x.sumchans__Owner_Manager__c === sups[i];
                    }).length;                         
                }

 
Here in this code below I have an opportunities array. When I click on diffferent tabs of the component the array should get filtered with the appropriate selection of the tab. When the page loads, clicking on the first tab loads the right data, but clicking on another one returns an empty list. I know the original items of the array will get overwritten when you click on the second tab. How do I do the filtering from the original items of the array? How do I go about coding that?. New to programming.

Please advise!
tabSelect: function (component, event, helper) {
        var sup = component.get("v.selTabId");
        let oppsAll = component.get("v.opps");            
        let oppsbySup = oppsAll.filter(x => { 
            return x.sumchans__Owner_Manager__c === sup;
        });       
        component.set("v.opps", oppsbySup);
    }
Is there a way we could expand the tab horizontally to fill the entire width of the screen. I dont see an option anywhere on the reference to do that.
Please advise!
 
<lightning:tabset selectedTabId="two">
            <lightning:tab label="Item One" id="one">
            </lightning:tab>
            <lightning:tab label="Item Two" id="two">
            </lightning:tab>
            <lightning:tab label="Item Three" id="three">
            </lightning:tab>
        </lightning:tabset>

 
Select Name, CloseDate, StageName, sumchans__OppOwner__c From Opportunity where CloseDate < YESTERDAY and StageName = 'Overdue' and StageName = 'Won'

This is exaclty what I am trying to do, but it doesn't pull any data. I know there is something wrong here.

Please advise!
I am trying to pass the id of the row when the lightning input component gets focus or when the dropdown is clicked. Please adivse!
<aura:iteration items="{!v.opps}" var="opp">
<tr>
<td data-label="Close Date">
                            <lightning:input class="slds-size_x-small slds-align_absolute-center" type="date" value="{! opp.CloseDate }" onchange="{!c.onDateChange}" onfocus="{!c.onDateFocus}"/>
                        </td>
</tr>
</aura:iteration>

 
Hello All,
This is what I have got so far to update the Stage of an opportunity, unfortunately it doesn't work at all.
Helper.js
updateOppStage : function(component, selectedButtonLabel, selectedRecordId) {
        var updateOppCall = component.get("c.updateOppStage");
        console.log(selectedButtonLabel, selectedRecordId);
        updateOppCall.setParams(
            {
                oppId : selectedRecordId,
                oppStage : selectedButtonLabel
            }
        );
        updateOppCall.setCallback(this, function(response) {
            var state = response.getState();
            
            if (state === "SUCCESS") {
             	var result = response.getReturnValue();
                console.log(result);
            }            
        });
        $A.enqueueAction(updateOppCall);     
    }
Apex Class Controller
@AuraEnabled
    public static Opportunity updateOppStage(String oppId, String oppStage) {
        Opportunity opp = [Select Name, CloseDate, StageName, sumchans__OppOwner__c From Opportunity where Id:=oppId];
        opp.StageName = oppStage;
        update opp;
		return opp;
    }
Please advise !

Thanks all!

 
Hello all,
Totally new to Javascript.
I am trying to pass values from the controller.js to the helper.js file. Here in the below code I am trying to pass the 'selectedRecordId' and the 'selectedButtonLabel' variable to the helper.js file. Not sure how to do it in JS.

Here is my controller code:
({
   handleRowAction :function(component, event, helper){
       var selectedButtonLabel = event.getSource().get("v.label");
        var selectedRecordId = event.getSource().get("v.value");
        helper.updateOppStage(component, event, helper);
  }
})
Here is my helper code:
({   
    updateOppStage : function(component, event, helper) {
        var action = component.get("c.findById");
    }
})
Here is my apex code:
public class OppsListApexController {
    @AuraEnabled
    public static Opportunity findById(String oppId) {
        return [select Name, CloseDate, StageName, sumchans__OppOwner__c from Opportunity where id=:oppId];
    }
}


Please advise!

Thanks
Hello,

I am trying to add a button column to a lightning datatable with each button in that column to have the value from the serverCall. I got to this point, but it doesn't display the value. New to Saleforce & Javascript.
<lightning:datatable keyField="id" data="{! v.opps }" columns="{! v.columns }" 
                             hideCheckboxColumn="true" onrowaction="{! c.handleRowAction }"/>
component.set('v.columns', [     
            {label: 'Opportunity name', fieldName: 'Name', type: 'text'},
            {label: 'Close Date', fieldName: 'CloseDate', type: 'date', editable: 'true', cellAttributes: { iconName: 'utility:event', iconAlternativeText: 'Close Date' }},
            {label: 'Action', fieldName: 'StageName', type: 'button', typeAttributes: { iconName: 'utility:view', label: 'View Record', fieldName: 'StageName', name: 'viewRecord', disabled: false, value: 'viewBtn', variant:{fieldName: 'StageName'}}}
		]);

 
Hello all,
I am looking to have buttons change color, depending on the value received from the server.  I have a stage column from the Opportunity object, I want the buttons on each column change their color based on the current stage. 
For example, WON - OVERDUE - CLOSED LOST - CLOSED WON,  would be the 4 button columns with fixed titles, depending on the value from the server the buttons should change their colour to green. If the stage is at Overdue the WON & OVERDUE Column button should chnage their background color to green. How to do this?

I was able to put a button the Lightning Datatable with the values from the server.
component.set('v.columns', [     
            {label: 'Opportunity name', fieldName: 'Name', type: 'text'},
            {label: 'Close Date', fieldName: 'CloseDate', type: 'date', editable: 'true', cellAttributes: { iconName: 'utility:event', iconAlternativeText: 'Close Date' }},
            {type: 'button',typeAttributes: { label: {fieldName: 'StageName'}, 
    										  name: 'editRecord', 
    										  title: 'editTitle', 
    										  disabled: false, 
    										  value: 'test',
  }},

Please advise
 
Just a newbie to salesforce development and Javascript as well. I got it done this way, it doesn't seem to show anything. Just taking it step by step
({
    fetchOpps : function(component, event, helper) {
        var actions = [
            {label: 'Overdue', name: 'selectRecord'},
            {label: 'Closed Won', name: 'closedWon'}
        ];
        component.set('v.columns', [
            {type: 'action', typeAttributes: {rowActions: actions}},
            {type: "button", typeAttributes: {
                             iconName: 'utility:add',
                             label: '',
                             name: 'selectRecord',
                             title: 'selectRecord',
                             disabled: false,
                             value: 'test',
            }},
            {type: "buttonGroup", typeAttributes: {
                             iconName: 'action:approval',
                             label: '',
                             name: 'selectRecord',
                             title: 'selectRecord',
                             disabled: false,
                             value: 'test',
            }},
            {type: "button", typeAttributes: {
                             iconName: 'action:approval',
                             label: '',
                             name: 'selectRecord',
                             title: 'selectRecord',
                             disabled: false,
                             value: 'test',
            }},

            {label: 'Opportunity name', fieldName: 'Name', type: 'text'},
            {label: 'Close Date', fieldName: 'CloseDate', type: 'date'},
            {label: 'Stage', fieldName: 'StageName', type: 'picklist'},
        ]);
            helper.fetchOpportunities(component, event, helper);
    },
Please advise!

Thanks
 
I am trying to use the DML statement to make an insert to the parent and child tables all at once.

I have got it to this point so far, I am not sure how to link the child to the parent when doing the insert in one command.

I tried following the instructions on the post below, got a bit confused. On the code there they use an external ID to make it happen which I am not sure about as I want the child objects to have the id of the parent record on its foreign key relationship field. I already have a master-detail relationship setup between the custom objects.

https://salesforce.stackexchange.com/questions/133906/insert-list-of-parent-and-child-records-in-one-dml-statement][1]

Here is what I go to so far. How do I link the 2 objects using the master-detail relationship setup and how to use the insert statement.
 
List<addressMaster__c> mduMaster = new List<addressMaster__c>();
            List<addressDetail__c> mduDetails = new List<addressDetail__c>();         
            Object[] values = (Object[])System.JSON.deserializeUntyped(mdus);
            for( Object mdu : values) {
                Map<String,Object> data = (Map<String,Object>)mdu;
                streetAddress = String.valueof(data.get('streetAddress'));
                totalUnits = Integer.valueof(data.get('totalUnits'));
                nnUnits = Integer.valueof(data.get('nnUnits'));            
                addressDetail__c newMduDetail = new addressDetail__c(Name=streetAddress,nnUnits__c=nnUnits,lastReportDate__c=DateTime.now());                                                         
                addressMaster__c newMduMaster = new addressMaster__c(Name=streetAddress,totalUnits__c=totalUnits);
                    
                mduDetails.add(newMduDetail);
                mduMaster.add(newMduMaster);
            }
Please advise!
 
How do i add a space in between the sup.name & sup.count and also how do I change the font color of the sup.count part

<aura:set attribute="label">
   {!sup.name} <b style="color:red">({!sup.count})</b>
 </aura:set>

This simple doesn't work at all.

 
Here in this code below I have an opportunities array. When I click on diffferent tabs of the component the array should get filtered with the appropriate selection of the tab. When the page loads, clicking on the first tab loads the right data, but clicking on another one returns an empty list. I know the original items of the array will get overwritten when you click on the second tab. How do I do the filtering from the original items of the array? How do I go about coding that?. New to programming.

Please advise!
tabSelect: function (component, event, helper) {
        var sup = component.get("v.selTabId");
        let oppsAll = component.get("v.opps");            
        let oppsbySup = oppsAll.filter(x => { 
            return x.sumchans__Owner_Manager__c === sup;
        });       
        component.set("v.opps", oppsbySup);
    }
Is there a way we could expand the tab horizontally to fill the entire width of the screen. I dont see an option anywhere on the reference to do that.
Please advise!
 
<lightning:tabset selectedTabId="two">
            <lightning:tab label="Item One" id="one">
            </lightning:tab>
            <lightning:tab label="Item Two" id="two">
            </lightning:tab>
            <lightning:tab label="Item Three" id="three">
            </lightning:tab>
        </lightning:tabset>

 
Select Name, CloseDate, StageName, sumchans__OppOwner__c From Opportunity where CloseDate < YESTERDAY and StageName = 'Overdue' and StageName = 'Won'

This is exaclty what I am trying to do, but it doesn't pull any data. I know there is something wrong here.

Please advise!
I am trying to pass the id of the row when the lightning input component gets focus or when the dropdown is clicked. Please adivse!
<aura:iteration items="{!v.opps}" var="opp">
<tr>
<td data-label="Close Date">
                            <lightning:input class="slds-size_x-small slds-align_absolute-center" type="date" value="{! opp.CloseDate }" onchange="{!c.onDateChange}" onfocus="{!c.onDateFocus}"/>
                        </td>
</tr>
</aura:iteration>

 
Hello All,
This is what I have got so far to update the Stage of an opportunity, unfortunately it doesn't work at all.
Helper.js
updateOppStage : function(component, selectedButtonLabel, selectedRecordId) {
        var updateOppCall = component.get("c.updateOppStage");
        console.log(selectedButtonLabel, selectedRecordId);
        updateOppCall.setParams(
            {
                oppId : selectedRecordId,
                oppStage : selectedButtonLabel
            }
        );
        updateOppCall.setCallback(this, function(response) {
            var state = response.getState();
            
            if (state === "SUCCESS") {
             	var result = response.getReturnValue();
                console.log(result);
            }            
        });
        $A.enqueueAction(updateOppCall);     
    }
Apex Class Controller
@AuraEnabled
    public static Opportunity updateOppStage(String oppId, String oppStage) {
        Opportunity opp = [Select Name, CloseDate, StageName, sumchans__OppOwner__c From Opportunity where Id:=oppId];
        opp.StageName = oppStage;
        update opp;
		return opp;
    }
Please advise !

Thanks all!

 
Hello all,
Totally new to Javascript.
I am trying to pass values from the controller.js to the helper.js file. Here in the below code I am trying to pass the 'selectedRecordId' and the 'selectedButtonLabel' variable to the helper.js file. Not sure how to do it in JS.

Here is my controller code:
({
   handleRowAction :function(component, event, helper){
       var selectedButtonLabel = event.getSource().get("v.label");
        var selectedRecordId = event.getSource().get("v.value");
        helper.updateOppStage(component, event, helper);
  }
})
Here is my helper code:
({   
    updateOppStage : function(component, event, helper) {
        var action = component.get("c.findById");
    }
})
Here is my apex code:
public class OppsListApexController {
    @AuraEnabled
    public static Opportunity findById(String oppId) {
        return [select Name, CloseDate, StageName, sumchans__OppOwner__c from Opportunity where id=:oppId];
    }
}


Please advise!

Thanks
Just a newbie to salesforce development and Javascript as well. I got it done this way, it doesn't seem to show anything. Just taking it step by step
({
    fetchOpps : function(component, event, helper) {
        var actions = [
            {label: 'Overdue', name: 'selectRecord'},
            {label: 'Closed Won', name: 'closedWon'}
        ];
        component.set('v.columns', [
            {type: 'action', typeAttributes: {rowActions: actions}},
            {type: "button", typeAttributes: {
                             iconName: 'utility:add',
                             label: '',
                             name: 'selectRecord',
                             title: 'selectRecord',
                             disabled: false,
                             value: 'test',
            }},
            {type: "buttonGroup", typeAttributes: {
                             iconName: 'action:approval',
                             label: '',
                             name: 'selectRecord',
                             title: 'selectRecord',
                             disabled: false,
                             value: 'test',
            }},
            {type: "button", typeAttributes: {
                             iconName: 'action:approval',
                             label: '',
                             name: 'selectRecord',
                             title: 'selectRecord',
                             disabled: false,
                             value: 'test',
            }},

            {label: 'Opportunity name', fieldName: 'Name', type: 'text'},
            {label: 'Close Date', fieldName: 'CloseDate', type: 'date'},
            {label: 'Stage', fieldName: 'StageName', type: 'picklist'},
        ]);
            helper.fetchOpportunities(component, event, helper);
    },
Please advise!

Thanks