0

I have created a custom object work_order__c in this custom object i have created a case field as a master-detail to work_order__c. How can i get the case id in VF page for saving the workorder? I am using angularjs in VF page and its a new attempt.

please help.

<apex:page standardController="Work_Order__c" extensions="WorkOrderControllerExtension">

   <apex:inputField value="{!Work_Order__c.Case__c}" html-ng-model="workorder.Case__r.id"/>
1

It is clear you are trying to get parent Case__c Id..

It is simple.. If you check {!Work_Order__c.Case__c} in VF this will display Case Id.

like

<apex:outputText value="{!Work_Order__c.Case__c}"/>

This will print Case Id

When we use apex:inputField. Salesforce create a lookup for us.. But in actual {!Work_Order__c.Case__c} field contain the Case Id.

<apex:inputField value="{!Work_Order__c.Case__c}" />

Let me know if you need any clarification

| improve this answer | |
  • I tried the same earlier it gives me error. Upsert failed. First exception on row 0; first error: MALFORMED_ID, Case: id value of incorrect type: 00001006: [Case__c] It is displaying case number as expected but while saving i need to save case id. – Ejaz Jan 15 '16 at 10:15
  • Yes, i am selecting case record from lookup. I am debugging from browser as it is client side code. I gives me case number. – Ejaz Jan 15 '16 at 10:21
  • @Ratan Wouldn't it be {!Work_Order__r.Case__c}? – Dan Jones Jan 15 '16 at 10:37
  • 1
    @Poet standardController="Work_Order__c" so I believe Case__c is just a field on Work_Order__c object correct? – Ratan Paul Jan 15 '16 at 10:39
  • 1
    00001006 looks like a CaseNumber, not a Case ID. In your schema, is {!Work_Order__c.Case__c} a lookup to case or a formula field to CaseNumber? – cropredy Jan 19 '16 at 18:09

Not the answer you're looking for? Browse other questions tagged or ask your own question.