• erikvm
  • NEWBIE
  • 20 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 9
    Replies

I've got a lightning component that lets the user submit a record. Once they hit submit, the standard page for creating the record pops up, which looks like this:


User-added image

 

Is it possible to customize this modal to only display certain things? I'd like it to look like a confirmation page (as they have entered the information for each field in a previous component), something along the lines of

 

"You entered:

Date xx

Dealer: YY

Press save to confirm"

Here's the code for that modal popup:

loadSalesAppointment: function(component, event, helper, customerAccountId) {
        var event = $A.get("event.force:createRecord");     
        if (event) {
            event.setParams({
                entityApiName: "Sales_Appointment__c",
                defaultFieldValues: {
                    Resource__c: component.get("v.resourceId"),
                    Dealership__c: component.get("v.accountId"),
                    Lead__c: component.get("v.customerAccountId"),
                    Start__c : StartDateAndTime,
                    End__c : EndDateAndTime
                }
            })
            event.fire();
        }
        else {
            alert("Not available")
        }
    },
  • April 30, 2018
  • Like
  • 0
I've got a lightning:datatable that looks like this: 
<aura:attribute name="resources" type="Object"/> 
<aura:attribute name="mycolumns" type="List"/> 
<aura:handler name="init" value="{! this }" action="{! c.doInit }"/> 
<lightning:datatable 
data="{! v.resources }" 
columns="{! v.mycolumns }" 
keyField="Id" 
onrowaction="{! c.handleRowAction }" 
hideCheckboxColumn="true" />

with a doInit that looks like this:

doInit: function (component, event, helper) {
        var actions = [
                    { label: 'Select', name: 'selectRecord' },
                ];
        component.set('v.mycolumns', [
                        {type: 'action', typeAttributes: {
                        rowActions: actions,

                        }},
                        {type: "button", typeAttributes: {
                             iconName: 'utility:add',
                             label: '',
                             name: 'selectRecord',
                             title: 'selectRecord',
                             disabled: false,
                             value: 'test',
                             }},
                        {label: 'Resource', fieldName: 'Name', type: 'text'},
                        {label: 'Comment', fieldName: 'Comment__c', type: 'text'},

                    ]);
            },
 
handleRowAction: function (component, event, helper) {
        var action = event.getParam('action');
        var row = event.getParam('row');
        switch (action.name) {
            case 'selectRecord':
                console.log(row.Id);
                console.log('Showing Details: ' + JSON.stringify(row));
                break;

Here's my issue: I want the button to handle the handleRowAction. I don't want a dropdown menu - how can I make my button handle the action? What's the point of having a button on the lightning:datatable if I can't do anything with it? As of now it seems that only "action" can handle stuff like "select this row" etc.
 
  • April 25, 2018
  • Like
  • 0
Hello,

I'm trying to add a custom object lookup field to a Visualforce page - how can I go about doing this? This lookup field also has some logic (depending on what value you select in Lookup 1, Lookup 2 will display different values) - I want to let users outside Salesforce to be able to do this.

Any help is appreciated,
thanks
  • January 15, 2018
  • Like
  • 0
Hi,

I'm trying to write a test class for my trigger. I tried the trigger in my environment and it works fine, but I can't get the code coverage on the test class, and not really sure how. Here's what the trigger looks like:
trigger AccountTrigger on Account (before insert) {
	list<Account> Acc = [SELECT Id, Name, Generated_ID__c FROM Account WHERE Generated_ID__c != null ORDER BY Generated_ID__c DESC LIMIT 1];
	String Record_ID = Schema.SObjectType.Account.getRecordTypeInfosByName().get('Billing').getRecordTypeId();

    if(Acc.size() > 0){
    	decimal maxLead = Acc[0].Generated_ID__c;
	    for (Account acco : Trigger.new) {
	        if (acco.RecordTypeId == Record_ID) {
	            acco.Generated_ID__c = Integer.valueOf(maxLead)+1;
	            maxLead++;
	        }
	    }
    }
}

And my test class:

@IsTest
private class GenerateExternalIdTest {
    private static String Record_ID = Schema.SObjectType.Account.getRecordTypeInfosByName().get('Billing').getRecordTypeId();

    @isTest static  void createNewAccount() {
        Account newAccount = (Account) TestDataGenerator.createSObject(new Account(RecordTypeId = Record_ID),'TestDataGenerator.AccountDefaults');
        insert newAccount;

    }
}

My issue is that I don't know where to put the query. Right now, the test class code coverage is 37,5% - it skips the actual loop.
 

Thanks in advance!

  • October 20, 2017
  • Like
  • 0
I have recently started learning about triggers and classes in Apex. One thing I'm unsure about is deploying triggers to the developer edition. I know you can't push code directly to a production environment without getting 75% code coverage, but what if my triggers that I deploy in the developer edition conflicts with other triggers / SObjects? Are people writing test classes somehow before uploading the trigger to the developer edition (for instance if you're using Eclipse or some other IDE)
  • October 05, 2017
  • Like
  • 0

I've got a lightning component that lets the user submit a record. Once they hit submit, the standard page for creating the record pops up, which looks like this:


User-added image

 

Is it possible to customize this modal to only display certain things? I'd like it to look like a confirmation page (as they have entered the information for each field in a previous component), something along the lines of

 

"You entered:

Date xx

Dealer: YY

Press save to confirm"

Here's the code for that modal popup:

loadSalesAppointment: function(component, event, helper, customerAccountId) {
        var event = $A.get("event.force:createRecord");     
        if (event) {
            event.setParams({
                entityApiName: "Sales_Appointment__c",
                defaultFieldValues: {
                    Resource__c: component.get("v.resourceId"),
                    Dealership__c: component.get("v.accountId"),
                    Lead__c: component.get("v.customerAccountId"),
                    Start__c : StartDateAndTime,
                    End__c : EndDateAndTime
                }
            })
            event.fire();
        }
        else {
            alert("Not available")
        }
    },
  • April 30, 2018
  • Like
  • 0
I've got a lightning:datatable that looks like this: 
<aura:attribute name="resources" type="Object"/> 
<aura:attribute name="mycolumns" type="List"/> 
<aura:handler name="init" value="{! this }" action="{! c.doInit }"/> 
<lightning:datatable 
data="{! v.resources }" 
columns="{! v.mycolumns }" 
keyField="Id" 
onrowaction="{! c.handleRowAction }" 
hideCheckboxColumn="true" />

with a doInit that looks like this:

doInit: function (component, event, helper) {
        var actions = [
                    { label: 'Select', name: 'selectRecord' },
                ];
        component.set('v.mycolumns', [
                        {type: 'action', typeAttributes: {
                        rowActions: actions,

                        }},
                        {type: "button", typeAttributes: {
                             iconName: 'utility:add',
                             label: '',
                             name: 'selectRecord',
                             title: 'selectRecord',
                             disabled: false,
                             value: 'test',
                             }},
                        {label: 'Resource', fieldName: 'Name', type: 'text'},
                        {label: 'Comment', fieldName: 'Comment__c', type: 'text'},

                    ]);
            },
 
handleRowAction: function (component, event, helper) {
        var action = event.getParam('action');
        var row = event.getParam('row');
        switch (action.name) {
            case 'selectRecord':
                console.log(row.Id);
                console.log('Showing Details: ' + JSON.stringify(row));
                break;

Here's my issue: I want the button to handle the handleRowAction. I don't want a dropdown menu - how can I make my button handle the action? What's the point of having a button on the lightning:datatable if I can't do anything with it? As of now it seems that only "action" can handle stuff like "select this row" etc.
 
  • April 25, 2018
  • Like
  • 0
Hi,

I'm trying to write a test class for my trigger. I tried the trigger in my environment and it works fine, but I can't get the code coverage on the test class, and not really sure how. Here's what the trigger looks like:
trigger AccountTrigger on Account (before insert) {
	list<Account> Acc = [SELECT Id, Name, Generated_ID__c FROM Account WHERE Generated_ID__c != null ORDER BY Generated_ID__c DESC LIMIT 1];
	String Record_ID = Schema.SObjectType.Account.getRecordTypeInfosByName().get('Billing').getRecordTypeId();

    if(Acc.size() > 0){
    	decimal maxLead = Acc[0].Generated_ID__c;
	    for (Account acco : Trigger.new) {
	        if (acco.RecordTypeId == Record_ID) {
	            acco.Generated_ID__c = Integer.valueOf(maxLead)+1;
	            maxLead++;
	        }
	    }
    }
}

And my test class:

@IsTest
private class GenerateExternalIdTest {
    private static String Record_ID = Schema.SObjectType.Account.getRecordTypeInfosByName().get('Billing').getRecordTypeId();

    @isTest static  void createNewAccount() {
        Account newAccount = (Account) TestDataGenerator.createSObject(new Account(RecordTypeId = Record_ID),'TestDataGenerator.AccountDefaults');
        insert newAccount;

    }
}

My issue is that I don't know where to put the query. Right now, the test class code coverage is 37,5% - it skips the actual loop.
 

Thanks in advance!

  • October 20, 2017
  • Like
  • 0