• Francesco Carmagnola 10
  • NEWBIE
  • 10 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 4
    Questions
  • 12
    Replies
I am passing a list of Object from my Lightning Component to the Apex Controller. The variable is called "fieldList" and is declared as parameter. If I run this code, just for debug pourpose:
 
@AuraEnabled
public static SObject[] getExistingRecords(SObject item, Object[] fieldList, String[] parameterList){
    system.debug('@@fieldList: '+fieldList);
    for(Object field: fieldList){
         system.debug('@@field: '+field);
    }
}

I obtain this debug LOG:

11:50:58:000 VARIABLE_ASSIGNMENT [56]|fieldList|{"s":1,"v":[{"name":"FirstName","type":"inputField","required":true},{"name":"LastName","type":"inputField","required":true},{"name":"Phone","type":"inputField","required":true},{"name":"Email","type":"inputField"}]}|0x5c6aaa7e

11:50:58:001 USER_DEBUG [57]|DEBUG|@@fieldList: ({name=FirstName, type=inputField, required=true}, {name=LastName, type=inputField, required=true}, {name=Phone, type=inputField, required=true}, {name=Email, type=inputField})

And then, entering the loop

11:50:58:019 FATAL_ERROR System.UnexpectedException: Salesforce System Error: 1668576522-38148 (152924272) (152924272)

As you can see in the first debug, the List of Objects doesn't seem a list at all...
Bug?
I've created a component which accepts as an attribute an SObject. When I simply pass a JSON SObject to it, like:
 
<c:ChildCreatorComponent obj="{
                                        sobjectType : 'Contact',
                                        LastName : 'Rossi',
                                        FirstName : 'Mario'
                                    }" />
Everything is fine. But right now, I need to pass a dynamic value (like an ID):
 
<c:ChildCreatorComponent obj="{
                                        sobjectType : 'Contact',
                                        AccountId : MY_DYNAMIC_ID,
                                        LastName : 'Rossi',
                                        FirstName : 'Mario'
                                    }" />
If I try to insert my ID with an expression, as I would do in Visualforce, I obtain an error. Example:
<c:ChildCreatorComponent obj="{
                                            sobjectType : 'Contact',
                                            AccountId : {!v.recordId},
                                            LastName : 'Rossi',
                                            FirstName : 'Mario'
                                        }" />
"Cannot mix expression and literal string in attribute value, try rewriting like {!'foo' + v.bar}: Source"

But if I do that, I am passing a String instead of an SObject to the component.
Any idea? I want to keep the simplest as possible the component attribute structure.. So I can not create other attribute for the dynamic field values.
Hello,
when I try to save this Lighting App:
 
<aura:application extends="force:slds">
</aura:application>

SF returns that error:

[ERROR]: No APPLICATION named markup://force:slds found : [markup://c:CampingApp]

As it is referenced here, I need it to use the Lighnting Design System without put it in a static resource:

https://www.lightningdesignsystem.com/platforms/lightning/

 
Hi all,

I've got a problem. I've got this situation: a controller with a VF page and a wrapper class. Here a summary of the code:

WRAPPER:
public with sharing class DisplayOptionHelper {
    
    public Map<Integer, OptionsInLineaOrdineWrapper> mapDisplay {get; set;}
    public List<OptionsInLineaOrdineWrapper> listDisplay {get; set;}

    private Map<Integer, ProdottoListino__c>  mapAllOptions ;
    Map<Integer, OptionsInLineaOrdineWrapper> mapInsertOptions;

}
In the controller I put the declaration of the wrapper:
 
public DisplayOptionHelper displayOptions {get;set;}

Finally, in page I've got a Table like this:
 
<apex:pageBlockTable value="{!displayOption.listDisplay}" var="c" id="optionsPBSection" >


Now, I've got this problem: the variable mapAllOptions it is included in the view state, but I don't need it in page! How can bind just the wrapper variable "listOption"? transient on mapAllOptions doesn't work for me as I call the variable in many methods of the wrapper.

Thanks!




 

Hi, I have created a Lightning Web Component to be used as pre-chat for an Einstein bot. 
When we test the Embedded Service Deployment on a Visualforce page, everything runs smoothly.
Nevertheless, on an external website (company website), the stylying of this component is completely lost and the input fields look very basic (as lacking any stylying whatsoever).

I have read that I should use Lightning Out to wrap LWC for external use but that is not working at all.

Any idea?
I have a record edit form that works for me, but "rarely" works for another user (I'm logging in as that user to test this) -- but here's the kicker -- *until* they go do other stuff and come back later.

The lightning component consists of a lightning:recordEditForm that has several fields including about 4 lookup fields (Account, Contact, managed obj Vehicle Inventory and managed obj Location). One of the lookups is to a custom object, and gets a default value based on the user's settings. When creating a new record, the default value shows up properly. The record is saved and that location lookup value is in the record -- it's visible in the "Recent items" related list.  But when this user re-opens the record that value isn't there anymore. 

When the value will NOT display on-screen I'm seeing an error 4 times in my Chrome consols: "Cannot read property 'color' of undefined.'  This error occurs *between* the completion of my "init" handler and the start of the RecordEditForm's onload method. The "setDefaultLocation" routine runs correctly when initiating a new record, but does not run (and shouldn't) when displaying an existing record with the value specified.

I've verified that the user has read & edit authority on all fields in the object and can read the target object of the lookup field. And again, if I log off as this user, then log in as this user again (or just go on to other things and come back later), then the lookup field is properly displayed.

I think the full code is too much for the forum, but here are some snippets:

<aura:component implements="flexipage:availableForRecordHome,force:hasRecordId,force:appHostable,lightning:actionOverride"
    controller="RentalAgreementLex">
...
    <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
...
<lightning:recordEditForm recordId="{!v.recordId}" objectApiName="dealer__Rental_Agreements__c"
    aura:id="newrecordform" onsuccess="{!c.recordSaved}" onerror="{!c.recordSaveError}"
    onload="{!c.pageload}">
...
            <lightning:inputField fieldName="Location__c" disabled="{!v.alreadyposted}" aura:id="location"
                required="true" readonly="{!v.alreadyposted}" class="mw_required"/>


Some of the controller code:
/* general page initializations */
    doInit : function(component, event, helper) {
        console.log('doInit');
        // initialize that we're not in the process of posting
        component.set("v.posting", false);
...
        console.log('doInit complete');
    },
    /* initializations when recordeditform is loaded */
    pageload: function(component, event, helper) {
        console.log('pageload');
        let id = component.get("v.recordId");
        console.log(id);
        let sts = (id==null) ? null : component.find("agreement_status").get("v.value");
        if (id==null) {
            sts = 'Open';   // default value
            let stscmp = component.find("agreement_status");
            if (stscmp!=null) stscmp.set("v.value", sts);
            component.set("v.status", sts); // also init record data status
            component.find("deposit_amount").set("v.value",0.00);   // default value
            component.find("excess_miles_charge").set("v.value",0.00);  // default value
            component.set("v.title","New Rental Agreement");
            component.find("totalperdiemtax").set("v.value",0.00);  // default value
            component.find("sales_tax").set("v.value",0.00);    // default value
            component.find("countysalestax").set("v.value",0.00);   // default value
            component.find("citysalestax").set("v.value",0.00); // default value
            component.find("thirdtierrentaltax").set("v.value",0.00);   // default value
        }
        // in doInit: component.set("v.title", name);
        let isopen = sts!='Paid';
        let posting = component.get("v.posting");
        console.log('isopen = ' + isopen);
        // enable/disable buttons based on rental status
        if (!posting && isopen) component.find("submitbutton").set("v.disabled", false);
        if (!posting && id!=null && isopen) component.find("postbutton").set("v.disabled",false);
        let fromaccount = component.get("v.fromaccount");
        if (fromaccount!==null) {
            component.find("account").set("v.value",fromaccount);
            helper.rtvPersonContactId(component, event);
        }
        let fromcontact = component.get("v.fromcontact");
        if (fromcontact!==null) {
            component.find("contact").set("v.value",fromcontact);
            helper.rtvContactsAccountId(component, event);
        }
        if (isopen) component.set("v.alreadyposted", false);
        else component.set("v.alreadyposted", true);
        // set default location
        let c_location = component.find("location");
        let location = null;
        if (c_location!=null) location = c_location.get("v.value");
        if (id==null && location==null) helper.rtvUserDefaultLocation(component, event);
        // initialize running totals
        helper.recalcTotals(component, event);
        console.log('pageLoad complete');
    },
 
I am passing a list of Object from my Lightning Component to the Apex Controller. The variable is called "fieldList" and is declared as parameter. If I run this code, just for debug pourpose:
 
@AuraEnabled
public static SObject[] getExistingRecords(SObject item, Object[] fieldList, String[] parameterList){
    system.debug('@@fieldList: '+fieldList);
    for(Object field: fieldList){
         system.debug('@@field: '+field);
    }
}

I obtain this debug LOG:

11:50:58:000 VARIABLE_ASSIGNMENT [56]|fieldList|{"s":1,"v":[{"name":"FirstName","type":"inputField","required":true},{"name":"LastName","type":"inputField","required":true},{"name":"Phone","type":"inputField","required":true},{"name":"Email","type":"inputField"}]}|0x5c6aaa7e

11:50:58:001 USER_DEBUG [57]|DEBUG|@@fieldList: ({name=FirstName, type=inputField, required=true}, {name=LastName, type=inputField, required=true}, {name=Phone, type=inputField, required=true}, {name=Email, type=inputField})

And then, entering the loop

11:50:58:019 FATAL_ERROR System.UnexpectedException: Salesforce System Error: 1668576522-38148 (152924272) (152924272)

As you can see in the first debug, the List of Objects doesn't seem a list at all...
Bug?
Hi,

What are the advantages  of using Eclipce IDE over Force.com IDE.

Regards
Jansi

 
Hello,
when I try to save this Lighting App:
 
<aura:application extends="force:slds">
</aura:application>

SF returns that error:

[ERROR]: No APPLICATION named markup://force:slds found : [markup://c:CampingApp]

As it is referenced here, I need it to use the Lighnting Design System without put it in a static resource:

https://www.lightningdesignsystem.com/platforms/lightning/

 
Hi,

We were trying to get input from user through submit form in a lightning component and with that input values create a record in a custom object. We got the input by the following code:

    <aura:attribute name="custDetail" type="CustomerDetail__c[]"></aura:attribute>
    <aura:attribute name="customerInfo"  type="CustomerDetail__c" default="{            sobjectType: 'CustomerDetail__c' }" />
    <force:inputField value="{!v.customerInfo.Name}"/>
    <ui:button label="Edit Record" press="{!c.saveDetails}"/>


Our jscontroller looks like the following

({
    saveDetails : function(component, event, helper) 
    {
    
    var dets = component.get("v.customerInfo.Name");
        alert(dets);
        //console.log('dets::'  + dets);
        //debugger;
        
    helper.save(component,dets);
    }
})


We get the name in the alert correctly when we submit.


Next the helper is as following


({
    save: function(component, dets) {
    //Save the expense and update the view
    this.upsertDet(component, dets, function(a) {
        var dets3 = component.get("v.custDetail");
        dets3.push(a.getReturnValue());
        console.log('here'+dets3);
        component.set("v.custDetail", dets3);
    });
},
upsertDet : function(component, dets, callback) {
  var action = component.get("c.saveDetailsGiven");
  action.setParams({ 
      "dets": dets
  });
  if (callback) {
      action.setCallback(this, callback);
  }
  $A.enqueueAction(action);
}
})


Apex class::

public class saveCusDetails {
     @AuraEnabled 
    public static string saveDetailsGiven(CustomerDetail__c details) {
   
    upsert details;
        system.debug('#####'+ details);
    return details.Id;
}
}


There are no errors but the record is not getting created. Any help would be appreciated.

Thank you
  • June 22, 2016
  • Like
  • 0
Im Working on one scenario update description value in ContentDocument Object.
This my piece of code.
//Update Description value in ContentDocument object
        List<ContentDocument> lstcd = new List<ContentDocument>();
        for(ContentDocumentLink cdl: [SELECT Id, ContentDocument.Description, ContentDocumentId, ContentDocument.LatestPublishedVersionId FROM ContentDocumentLink WHERE LinkedEntityId = '500N0000002hZC9'])
        {
            ContentDocument cd = new ContentDocument();
            cd.id = cdl.ContentDocumentId;
            cd.Description = 'Testing';
            lstcd.add(cd);
        }

        update lstcd;
But im getting this Error: Compile Error: Field is not writeable: ContentDocument.Description

Please advise on this
Objects with a single layer work fine, but when I try to use an object that goes deeper than one layer I receive an unknown server error when trying to access the variable on the server side user parameter.get('objectPropertyName') see code below.

So this code works as gateway is a simple string. However whenever I try to make gateway an object I start getting errors
       /*******************************************************************************************************
        * @description Test saving configuration
        */
        var saveConfiguration = component.get("c.testSomething");

        // Set save configuration parameters.
        saveConfiguration.setParams({
            testSome : 'Hello World!',
            config : {
                gateway: 'Stripe'
            }
        });

        // Setup save configuration callback
        saveConfiguration.setCallback(this, function(a) {
                if (a.getState() === "SUCCESS") {
                   // Do something with return value
                } else if (a.getState() === "ERROR") {
                    $A.error("Errors", a.getError());
                    $A.log("Errors", a.getError());
                }
            });

        // Queue the transaction action
        $A.enqueueAction(saveConfiguration);



This code gives me an error when trying to access the parameter map in the server side controller. 
       /*******************************************************************************************************
        * @description Test saving configuration
        */
        var saveConfiguration = component.get("c.testSomething");

        // Set save configuration parameters.
        saveConfiguration.setParams({
            testSome : 'Hello World!',
            config : {
                gateway: 'Stripe'
            }
        });

        // Setup save configuration callback
        saveConfiguration.setCallback(this, function(a) {
                if (a.getState() === "SUCCESS") {
                   // Do something with return value
                } else if (a.getState() === "ERROR") {
                    $A.error("Errors", a.getError());
                    $A.log("Errors", a.getError());
                }
            });

        // Queue the transaction action
        $A.enqueueAction(saveConfiguration);




Here's my server side controller method:
@AuraEnabled
public static void testSomething(String testSome, Map<String, Object> config) {
    System.debug(config.get('gateway'));
}

So in summary whenever gateway is a simple string everything works... The second I try to use an object I start getting errors. I'd prefer to use one of my Apex classes instead of a Map<String, Object> for the parameter, but I was having no luck with that. Any help is much appreciated!
 
Normally when creating Javascript methods in Visualforce they exist in the same scope, e.g. you can call one method from another with parameters. Just as the two functions findNext() and findPrev() calls findAndFocus() here:
function findPrev() {
    search_index--;
    findAndFocus(text, search_index);
}

function findNext() {
    search_index++;
    findAndFocus(text, search_index);
}

function findAndFocus(str, stop_at) {
    // Do something
}
But when using Lightning how do you call one method from another?
({
    findPrev : function (component, event, helper) {
        search_index--;
        findAndFocus(text, search_index); // What to write here?
    },
    
    findNext : function (component, event, helper) {
        search_index++;
        findAndFocus(text, search_index); // What to write here?
    },

    findAndFocus : function(text, stop_at) {
        // Do something
    }
})
What is the best practice? Is it to move all methods for reuse into the helper client side Javascript file?
What if the helper file methods need to call other methods within the same helper Javascript file?

Any thoughts or ideas?
 
Hello,

I need to create a form on a parent's apex page that allows the user to enter field data for a child object and save new a new child record.  This child is part of a related list so I would also need to update the related list that is visible in the page as well.  I feel like this is pretty basic, yet I am struggling to figure out how to make it happen.

I have created a controller extension but I am not sure how to link the saveChild method to the fields in the form field.

Thanks!
Hi,

I wish to create Child records Using Custom Buttons in Parent records. I gave the below value in the field .

{!URLFOR( $Action.Division_Revenue__c.New, Division__c.Id )}  but when the page opens it does not take the URL but simply passes the same value as text to the address tab. Hence I get URL not found.

Could you kindly guide me in anything I am missing out.

Thank you,

Regards,
Christwin
Objects with a single layer work fine, but when I try to use an object that goes deeper than one layer I receive an unknown server error when trying to access the variable on the server side user parameter.get('objectPropertyName') see code below.

So this code works as gateway is a simple string. However whenever I try to make gateway an object I start getting errors
       /*******************************************************************************************************
        * @description Test saving configuration
        */
        var saveConfiguration = component.get("c.testSomething");

        // Set save configuration parameters.
        saveConfiguration.setParams({
            testSome : 'Hello World!',
            config : {
                gateway: 'Stripe'
            }
        });

        // Setup save configuration callback
        saveConfiguration.setCallback(this, function(a) {
                if (a.getState() === "SUCCESS") {
                   // Do something with return value
                } else if (a.getState() === "ERROR") {
                    $A.error("Errors", a.getError());
                    $A.log("Errors", a.getError());
                }
            });

        // Queue the transaction action
        $A.enqueueAction(saveConfiguration);



This code gives me an error when trying to access the parameter map in the server side controller. 
       /*******************************************************************************************************
        * @description Test saving configuration
        */
        var saveConfiguration = component.get("c.testSomething");

        // Set save configuration parameters.
        saveConfiguration.setParams({
            testSome : 'Hello World!',
            config : {
                gateway: 'Stripe'
            }
        });

        // Setup save configuration callback
        saveConfiguration.setCallback(this, function(a) {
                if (a.getState() === "SUCCESS") {
                   // Do something with return value
                } else if (a.getState() === "ERROR") {
                    $A.error("Errors", a.getError());
                    $A.log("Errors", a.getError());
                }
            });

        // Queue the transaction action
        $A.enqueueAction(saveConfiguration);




Here's my server side controller method:
@AuraEnabled
public static void testSomething(String testSome, Map<String, Object> config) {
    System.debug(config.get('gateway'));
}

So in summary whenever gateway is a simple string everything works... The second I try to use an object I start getting errors. I'd prefer to use one of my Apex classes instead of a Map<String, Object> for the parameter, but I was having no luck with that. Any help is much appreciated!