Hi Mike,
Thanks for your reply. We have added the documents type.
But when we add custom fields, we get the null reference error:
System.NullReferenceException: Object reference not set to an instance of an object.
I searched in the forum, found few other posts which were also getting same error, tried their solutions, but nothing has worked so far in adding custom field values.
We have to add the custom fields while adding a task in service manager job, but it gives the null reference error in the first line:
- Code: Select all
var cfv = smjobtaskobj.CustomFieldValues.get_ItemFromSettingName("InvoiceNumber", "PluginName");
cfv.Contents = "NewInvoiceNo";
But then we tried with debtor and salesorder objects (as mentioned in the posts found on forum), using that same error is pointing to second line where we add the contents.
- Code: Select all
var cfv = salesorderobj.CustomFieldValues.get_ItemFromSettingName("InvoiceNumber", "PluginName");
cfv.Contents = "NewInvoiceNo";
Also tried creating new object from JiwaApplication.CustomFields.CustomFieldValue but that also results in same error.
It might be because we are creating a new job and a task in service manager, and salesorder and debtor are already created, so we tried a different approach (found in a post in the forum)
- Code: Select all
foreach (JiwaApplication.CustomFields.CustomFieldValue customFieldValue in salesorderobj.CustomFieldValues)
{
if (customFieldValue.CustomField.PluginCustomField.Name == "InvoiceNumber")
{
customFieldValue.Contents = "newinvoiceno";
}
}
This does not give any error, but it does not add in custom fields either.
I have checked and verified the Plugin name and Custom Field Name, both are correct. Even tried with get item from settingID, but still same error.
It is required that we put invoice number and other fields from invoice, like part number in the custom fields.
Sorry for the long post. But we really need help with this one.
Thanks