Answers for "{\"code\":\"MANDATORY_NOT_FOUND\",\"details\":{\"api_name\":\"data\"},\"message\":\"required field not found\",\"status\":\"error\"}\n"

PHP
0

{\"code\":\"MANDATORY_NOT_FOUND\",\"details\":{\"api_name\":\"data\"},\"message\":\"required field not found\",\"status\":\"error\"}\n

$moduleIns=ZCRMRestClient::getInstance()->getModuleInstance("Invoices"); //to get the instance of the module
$records=array();
$record=ZCRMRecord::getInstance("Invoices",null);  //To get ZCRMRecord instance
$record->setFieldValue("Subject","Invoice1"); //This function use to set FieldApiName and value similar to all other FieldApis and Custom field
$record->setFieldValue("Account_Name","554023000000366005"); //This function is for Invoices module

/** Following methods are being used only by Inventory modules **/

$lineItem=ZCRMInventoryLineItem::getInstance(null);  //To get ZCRMInventoryLineItem instance
$lineItem->setDescription("Product_description");  //To set line item description
$lineItem ->setDiscount(5);  //To set line item discount
$lineItem->setListPrice(100);  //To set line item list price

$taxInstance1=ZCRMTax::getInstance("VAT");  //To get ZCRMTax instance
$taxInstance1->setPercentage(2);  //To set tax percentage
$taxInstance1->setValue(50);  //To set tax value
$lineItem->addLineTax($taxInstance1);  //To set line tax to line item

$taxInstance1=ZCRMTax::getInstance("Sales_Tax"); //to get the tax instance
$taxInstance1->setPercentage(12); //to set the tax percentage
$taxInstance1->setValue(50); //to set the tax value
$lineItem->addLineTax($taxInstance1); //to add the tax to line item

$lineItem->setProduct(ZCRMRecord::getInstance("Price_Books",554023000000504001));  //To set product to line item
$lineItem->setQuantity(100);  //To set product quantity to this line item

$record->addLineItem($lineItem);   //to add the line item to the record

array_push($records, $record); //pushing the record to the array
$responseIn=$moduleIns->createRecords($records); //updating the records

foreach($responseIn->getEntityResponses() as $responseIns){
    echo "HTTP Status Code:".$responseIn->getHttpStatusCode();  //To get http response code
    echo "Status:".$responseIns->getStatus();  //To get response status
    echo "Message:".$responseIns->getMessage();  //To get response message
    echo "Code:".$responseIns->getCode();  //To get status code
    echo "Details:".json_encode($responseIns->getDetails());
}
Posted by: Guest on July-26-2020

Code answers related to "{\"code\":\"MANDATORY_NOT_FOUND\",\"details\":{\"api_name\":\"data\"},\"message\":\"required field not found\",\"status\":\"error\"}\n"

Browse Popular Code Answers by Language