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
Kevin Kim 9Kevin Kim 9 

I have code that needs to be reviewed

global class shipmentHandler{
    webservice static void copyPPtoSP(String strRecId){
        list<Shipment_Product__c> lstSP = new list <Shipment_Product__c>();

        List<ProjectProduct__c> lstPP = [Select Id
        , Quantity__c
        , Line_Description__c
        , List_Price__c
        , Product__c
        , Sales_Price__c
        , Total_Price__c
        , Unit__c
        , Project__c
        from ProjectProduct__c
        where Project__c =: strRecId];

        if(lstPP != null && !lstPP.isEmpty()){
            Shipment__c objShipment = new Shipment__c();
            objShipment.Name = lstPP[0].Project_r.Name;
            objShipment.Project__c = lstPP[0].Project__c;
            insert objShipment;

            for(ProjectProduct__c objO : lstPP){
                Shipment_Product__c objProd = new Shipment_Product__c();
                objProd.Name = objO.Name;
                objProd.Product__c = objO.Product__c;
                objProd.List_Price__c = objO.List_Price__c;
                objProd.Sales_Price__c = objO.Sales_Price__c;
                objProd.Quantity__c = objO.Quantity__c;
                objProd.Line_Description__c = objO.Line_Description__c;
                objProd.Unit__c = objO.Unit__c;
                objProd.ShipmentLookup__c = objShipment.Id;
                lstSP.add(objProd);
            }
        }
        if(!lstSP.isEmpty()){
            insert lstSP;
        }
    }
}
I'm basically trying to copy over the project products to the shipment custom object I made. They will be stored in Shipment products. But I keep getting an error: 

"No such column 'Project__c' on entity 'ProjectProduct__c'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names."

Need help. Please.
 
Eric PepinEric Pepin
If you are sure that the column Project__c exists on the ProjectProduct__c object, then it is probably permissions. Check to ensure that the Profile of the User executing the code has access to view this field. (Visible = true)