You need to sign in to do that
Don't have an account?
Martin S.
Illegal assignment from Case to String
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
I tryed to create a method that gets the recordId and then give it to the getCaseWithContact like:
But there I get the Error Illegal assignment from Case to String.
Can someone help me or give me a tipp?
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?
You're getting that error because ownerIdRec[0] is a Case, not a String. You'd want to use something like the following, depending on which Id you're actually looking for (I think the latter).
All Answers
You're getting that error because ownerIdRec[0] is a Case, not a String. You'd want to use something like the following, depending on which Id you're actually looking for (I think the latter).
But I thought wrong, we have a object with 2 related records (a account and a contact) and the method get the recordId from the account related record. So I need a possibility to get the recordId from the contact related record.
We have a switch (in the Helper.js) witch select the right method for the sql statement. The 'getContactInCase' method is from me and it makes the same like 'getCaseWithContact' witch select some data by recordId. Do you know how I can get here a recordId from a related record? The main object where I am in is 'case' and it has a Lookup to Contact with the recordId in VehicleOwner__c.
Can I access in js to that or was java right?
Thanks in advance!
We have a object "case" where when a customer calls all his information can be displayed. There we have a related record which points to a account (business contact / dealer) and a related record which points to a contact (to the consumer).
The actuall logic takes the recordId from the dealer account and get some infos for creating a link to another system.
I want to take the recordId from the consumer contact and create a link with that Id.
In the apex class there is already a method that get all contact informations and create that link so I need only to give from the helper.js the right recordId to apex and that should work I hope.
My first try was to make an sql statement in apex that get me the recordId like SELECT Contact.VehicleOwner__c FROM case WHERE Id = :CaseRecordId but that was not working and because the case object has a lookup field VehicleOwner__c to contact I thought it would be easier to get the Id direct in the Helper.js
Can't I make something like
Thanks for your time :)
//NavisionNavigator.cmp
NavisionNavigatorController.js
NavisionNavigatorHelper.js
The NavisionNavigator.design with the context cases
And the DataService that creates the choosen function
Here is how it looks in the Case:
In 1 the NavisionNavigator gets the recordId from the component and selects the data right. (Contact is here the Account of a dealer / reseller)
But in 2 it dont know how I can select there the recordId of the customer (who buys it from the reseller) from the "Halter"
Contact Details and Halter Details are both related records.
And in "Edit Page" I can select the context which are set in the NavisionNavigator.design
In the Apex class the last 2 functions were my attempt to implement this
I think that part of the issue is that DataService is being passed the task/function that it should call (getCaseWithContact, for example) based on the "context," but there doesn't seem to be any way for it to know it should call the methods you've since created. For example, you'd previously posted/asked: The answer to that question is, well, yes and no. The "context" of the page is going to ultimately determine what the "task" is. If my assumption regarding my initial question is correct and "context" is being set because you're on a case page, you may just be passing Contact.VehicleOwner__c to the getCaseWithContact method.
The context is set by the Lightning App Builder (Pages) - when I am at a case and click on "Edit this Page" I can insert the custom component NavisionNavigator. There I can choose from the entered list from NavisionNavigator.design And yes there should be a second rendered component.
I would have solved it that way after your answer, or is it too cumbersome? :