function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
RAJU_DEEPRAJU_DEEP 

Add new record through visualforce page.

Hello,

           Here i am having a object named "item" which is having a Master-Details relationship field "Shipping Invoice". I am trying to add new record but the problem is that when I insert the other fields record are easily inserted but the "Shipping Invoice" field I unable. The code which i have tried to store the record including all the fields except "Shipping Invoice" is below:

 

 

public void saveItems(){
Item__c sItem = new Item__c(
name = iName,
Price__c = price,
Quantity__c = quantity,
Weight__c = weight,
//Shipping_Invoice__c = shipInvoice
);
insert sItem;
}

 

Please help me how to insert the record...

Thanks in advance.

 

Imran MohammedImran Mohammed

Please paste the execption you are getting. That will help in understanding the exact issue you are into.

Are you passing ID value to Shipping_Invoice__c field in the below code? if not do so.

ScoobieScoobie

 


 

 

public void saveItems(){
Item__c sItem = new Item__c(
name = iName,
Price__c = price,
Quantity__c = quantity,
Weight__c = weight,
//Shipping_Invoice__c = shipInvoice
);
insert sItem;
}

 

Is it not 

 

Shipping_Invoice__c = shipInvoice.Id;

 

I think you are trying to assign an sObject to an ID field.

 

RAJU_DEEPRAJU_DEEP

Hello,

           Thanks for your reply i have tried that code and it shows this exception:

Illegal view ID saveItem. The ID must begin with /


I am unable to asign the id from user to the Shipping_Invoice__c (master-detail relationship field).