• Martin S.
  • NEWBIE
  • 10 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 6
    Replies
Hello,
I am trying to get the recordId in another component. Therefore I wrote a extra Apex method but I am not sure how to get the recordId there. 

Here I need to have the recordId of a Contact to get the right data
/**
   * Returns a case by its ID
   *
   * @param      id    The identifier
   *
   * @return     The case.
   */
  @AuraEnabled
  public static Case getCaseWithContact(Id id) {
    return [
      SELECT
        Id,
        Contact.Name,
        Contact.LastName,
        Contact.FirstName,
        Contact.MailingStreet,
        Contact.MailingCountry,
        Contact.Country_ISO_3166_2__c,
        Contact.MailingPostalCode,
        Contact.MailingCity,
        Contact.Phone,
        Contact.MobilePhone,
        Contact.Fax,
        Contact.Email,
        Contact.CustomerNumberNav__c,
        Contact.CustomerNumberSF__c,
        Contact.SalutationNavisionExport__c
        FROM Case WHERE Id = :id

    ];
  }

I tryed to create a method that gets the recordId and then give it to the getCaseWithContact like:
 
@AuraEnabled
  public static String getIdFromContactInCaseString(Id id) {

    List <case> ownerIdRec = [SELECT VehicleOwner__c FROM Case WHERE Id = :id];

    String ownerIdRecord = ownerIdRec[0];

    return ownerIdRecord;

  }

But there I get the Error Illegal assignment from Case to String.

Can someone help me or give me a tipp?
 
Hello,
I am trying to open a static ressource for a Aura Component. A company that programs components in SF for us, made a component with an Static Ressource. I need to add a class there but when I download the file (Setup- Static Ressources- Detail to static Ressource - show file) it has no file-extension. It is only "AuraServiceHelper". When I open the file with any programm/ or when I change the extension to .js/ .html etc. I get a salad of symbols. (£“̳Àã»\7²§ŸC20ëdœ&ã¿RÓe)

Can anyone say me, how I can edit this file right?

Name: AuraServiceHelper
Namespace-Präfix: -
Description: Contains javascript helper method to access AURA API faster in lightning components
MIME-Typ: application/octet-stream
Cache-Steuerung: Privat
Größe: 3.871 Byte

Thanks in advance,
Hello,
I try to show a child list on the contact page.
A contact has several vehicles. I want to select one and make some further processing. So I created a related list on the contact page. There you can now click on the vehicle that you want to choose and it opens vehicle-object-detail-page. There I want to have an flow that grabs somehow the ContactID from the contact. With the contact ID I can work further.
But when I start the flow at the vehicle-object-detail-page it only grabs the RecordID of the vehicle. I cant filter in the flow SELECT Name, E-Mail FROM Contact WHERE RecordID = Contact.Vehicle.ID
Can someone help me?
Hi,
I want to display a DataTable on the Contact Page and want to show in this list all products that the contact has bought. But I only get a blank table with only the table header. 
I am new to SF and just used this tutorial: sfdcmonkey- Lightning-datatable-base-component (http://sfdcmonkey.com/2018/01/05/lightning-datatable-base-component/)

I tried to change the sample data to my contact data but I got no Output. I also created a field-set under Contact pointing to my product object.

Server Side Controller – Apex Class LightningDataTableVehicleController
public class LightningDataTableVehicleController {
/*
	Method Name	: getAccRecords
	Purpose		: To get the wrapper of Columns and Headers
	*/
    @AuraEnabled
    public static DataTableResponse getAccRecords(String strObjectName, String strFieldSetName){                
       	
        //Get the fields from FieldSet
        Schema.SObjectType SObjectTypeObj = Schema.getGlobalDescribe().get(strObjectName);
        Schema.DescribeSObjectResult DescribeSObjectResultObj = SObjectTypeObj.getDescribe();            
        Schema.FieldSet fieldSetObj = DescribeSObjectResultObj.FieldSets.getMap().get(strFieldSetName);
        
        //To hold the table hearders 
        List<DataTableColumns> lstDataColumns = new List<DataTableColumns>();
        
        //Field to be queried - fetched from fieldset
        List<String> lstFieldsToQuery = new List<String>();
        
        //The final wrapper response to return to component
        DataTableResponse response = new DataTableResponse();
        
        for( Schema.FieldSetMember eachFieldSetMember : fieldSetObj.getFields() ){
            String dataType = String.valueOf(eachFieldSetMember.getType()).toLowerCase();
            //This way we can set the type of a column
            //We do not get the exact type from schema object which matches to lightning:datatable component structure
            if(dataType == 'datetime'){
                dataType = 'date';
            }
            //Create a wrapper instance and store label, fieldname and type.
            DataTableColumns datacolumns = new DataTableColumns( String.valueOf(eachFieldSetMember.getLabel()) , 
                                                                String.valueOf(eachFieldSetMember.getFieldPath()), 
                                                                String.valueOf(eachFieldSetMember.getType()).toLowerCase() );
			lstDataColumns.add(datacolumns);
            lstFieldsToQuery.add(String.valueOf(eachFieldSetMember.getFieldPath()));
        }
        
        //Form an SOQL to fetch the data - Set the wrapper instance and return as response
        if(! lstDataColumns.isEmpty()){            
            response.lstDataTableColumns = lstDataColumns;
            String query = 'SELECT Id, ' + String.join(lstFieldsToQuery, ',') + ' FROM Contact';
            System.debug(query);
            response.lstDataTableData = Database.query(query);
        }
        
        return response;
    }
    
    //Wrapper class to hold Columns with headers
    public class DataTableColumns {
        @AuraEnabled
        public String label {get;set;}
        @AuraEnabled       
        public String fieldName {get;set;}
        @AuraEnabled
        public String type {get;set;}
        
        //Create and set three variables label, fieldname and type as required by the lightning:datatable
        public DataTableColumns(String label, String fieldName, String type){
            this.label = label;
            this.fieldName = fieldName;
            this.type = type;            
        }
    }
    
    //Wrapper calss to hold response - This response is used in the lightning:datatable component
    public class DataTableResponse {
        @AuraEnabled
        public List<DataTableColumns> lstDataTableColumns {get;set;}
        @AuraEnabled
        public List<sObject> lstDataTableData {get;set;}                
        
        public DataTableResponse(){
            lstDataTableColumns = new List<DataTableColumns>();
            lstDataTableData = new List<sObject>();
        }
    }
}

LightningDataTableVehicle.cmp
 
<aura:component implements="flexipage:availableForAllPageTypes" controller="LightningDataTableVehicleController">
    <aura:attribute name="mydata" type="Object"/>
    <aura:attribute name="mycolumns" type="List"/>
 
    <aura:handler name="init" value="{!this}" action="{!c.doInit}" />
    
    <lightning:datatable data="{! v.mydata }" 
        columns="{! v.mycolumns }" 
        keyField="Id"/>
    
</aura:component>

LightningDataTableVehicleController.js
({
    doInit : function(component, event, helper) {		                
        helper.getDataHelper(component, event);
    },
})

LightningDataTableVehicleHelper.js
({
    getDataHelper : function(component, event) {
        var action = component.get("c.getAccRecords");
        //Set the Object parameters and Field Set name
        action.setParams({
            strObjectName : 'Contact',
            strFieldSetName : 'DataTableFieldSet'
        });
        action.setCallback(this, function(response){
            var state = response.getState();
            if(state === 'SUCCESS'){
                component.set("v.mycolumns", response.getReturnValue().lstDataTableColumns);
                component.set("v.mydata", response.getReturnValue().lstDataTableData);    
            }else if (state === 'ERROR'){
                var errors = response.getError();
                if (errors) {
                    if (errors[0] && errors[0].message) {
                        console.log("Error message: " +
                                    errors[0].message);
                    }
                } else {
                    console.log("Unknown error");
                }
            }else{
                console.log('Something went wrong, Please check with your admin');
            }
        });
        $A.enqueueAction(action);	
    }
})

And for displaying the data LightningDataTableVehicleTest.app
<aura:application  extends="force:slds">
	    <c:LightningDataTableVehicle />
</aura:application>

Then I went to my Contact page -> Edit this page  - and there I choose the DataTable.
The final look is:
User-added image

And that is the field-set I created under SF Classic - Setup - Contact Fieldset. I want to show all bought vehicles from a contact at the contact page and after that the goal is to choose one record and process with the id of the choosen vehicle.
User-added image 
​​​​​​​Thank you in advance for your help!
 
Hello,
I am trying to get the recordId in another component. Therefore I wrote a extra Apex method but I am not sure how to get the recordId there. 

Here I need to have the recordId of a Contact to get the right data
/**
   * Returns a case by its ID
   *
   * @param      id    The identifier
   *
   * @return     The case.
   */
  @AuraEnabled
  public static Case getCaseWithContact(Id id) {
    return [
      SELECT
        Id,
        Contact.Name,
        Contact.LastName,
        Contact.FirstName,
        Contact.MailingStreet,
        Contact.MailingCountry,
        Contact.Country_ISO_3166_2__c,
        Contact.MailingPostalCode,
        Contact.MailingCity,
        Contact.Phone,
        Contact.MobilePhone,
        Contact.Fax,
        Contact.Email,
        Contact.CustomerNumberNav__c,
        Contact.CustomerNumberSF__c,
        Contact.SalutationNavisionExport__c
        FROM Case WHERE Id = :id

    ];
  }

I tryed to create a method that gets the recordId and then give it to the getCaseWithContact like:
 
@AuraEnabled
  public static String getIdFromContactInCaseString(Id id) {

    List <case> ownerIdRec = [SELECT VehicleOwner__c FROM Case WHERE Id = :id];

    String ownerIdRecord = ownerIdRec[0];

    return ownerIdRecord;

  }

But there I get the Error Illegal assignment from Case to String.

Can someone help me or give me a tipp?
 
Hello,
I am trying to open a static ressource for a Aura Component. A company that programs components in SF for us, made a component with an Static Ressource. I need to add a class there but when I download the file (Setup- Static Ressources- Detail to static Ressource - show file) it has no file-extension. It is only "AuraServiceHelper". When I open the file with any programm/ or when I change the extension to .js/ .html etc. I get a salad of symbols. (£“̳Àã»\7²§ŸC20ëdœ&ã¿RÓe)

Can anyone say me, how I can edit this file right?

Name: AuraServiceHelper
Namespace-Präfix: -
Description: Contains javascript helper method to access AURA API faster in lightning components
MIME-Typ: application/octet-stream
Cache-Steuerung: Privat
Größe: 3.871 Byte

Thanks in advance,