I have created job site by using below mentioned code but when try to see created job site details Quantify app gets crashed. I have attached that error message.
Please advise.
RateProfileCollection oRateProfileCollection = RateProfileCollection.GetRateProfileCollection(ActiveStatus.Active, true, true, false);
Guid oRateProfile = new Guid();
oRateProfile = oRateProfileCollection[1].RateProfileID;
Guid oBP =new Guid();
BusinessPartner customer = BusinessPartner.GetBusinessPartnerByNumber("CUS-0000080");
if (customer.BusinessPartnerID == Guid.Empty)
{
customer = BusinessPartner.NewBusinessPartner(PartnerTypes.Vendor);
customer.AccountingID = "Test";
customer.Name = "Test";
customer.Save();
System.Windows.Forms.MessageBox.Show("Customer Created!!");
}
else
{
oBP = customer.BusinessPartnerID;
}
var oTradingPartner = TradingPartner.GetTradingPartner("Dubai");
StockingLocation Newjob = StockingLocation.NewStockingLocation(PartnerTypes.JobSite, oTradingPartner.TradingPartnerID);
// Set parent ID
//Newjob.ParentTradingPartnerID = oTradingPartner.TradingPartnerID;
Newjob.Name = "TestJobSite";
Newjob.BusinessPartnerID = oBP;
Newjob.DefaultRateProfileID = oRateProfile;
Newjob.BillingMethod = BillingMethodType.Arrears;
Newjob.FirstInvoiceDate = "3/30/2021";
Newjob.ArrearsBillingCycle = ArrearsBillingCycleType.Daily;
Newjob.CycleDaysArrears = 10;
try
{
if (Newjob.IsSavable)
{ Newjob.Save(); }
}
catch(Exception ex)
{
System.Windows.Forms.MessageBox.Show(ex.Message);
}
// Add other properties here
// Check broken rules and save