I’m getting Object reference error when inserting to Cache. Though I’m setting InvoiceCust value , exception is thrown stating InvoiceCust is null. Please see the code snippet below. Am doing anything wrong here?
Hi @vibindas. In your case, the error could be due to a couple of reasons:
The OldSchedule object might be null: You are creating a copy of OldSchedule and assigning some values from OldSchedule to newSchedule. If OldSchedule is null at this point, you will get a null reference exception. You should make sure OldSchedule is not null before you try to use it.
The ContractDetails View or its Cache might not be initialized: If you're trying to perform this operation in a graph extension, make sure the base graph is properly initialized. If this operation is being performed inside a row event handler, make sure the row is not null.
Try adding null checks to your code and also make sure you're executing this code in an appropriate context:
If you're still encountering issues, you may want to check the stack trace of the exception to find out the exact line of code where the exception is being thrown. This could provide more insights into the source of the problem.
@sweta68 , sorry if I phrased my question wrong. Issue is that though value is set for newSchedule.InvoiceCust = eg . “A”, while inserting newSchedule to View cache I can see the value is getting null thought it was set just before the insertion.
Hi @vibindas. In your case, the error could be due to a couple of reasons:
The OldSchedule object might be null: You are creating a copy of OldSchedule and assigning some values from OldSchedule to newSchedule. If OldSchedule is null at this point, you will get a null reference exception. You should make sure OldSchedule is not null before you try to use it.
The ContractDetails View or its Cache might not be initialized: If you're trying to perform this operation in a graph extension, make sure the base graph is properly initialized. If this operation is being performed inside a row event handler, make sure the row is not null.
Try adding null checks to your code and also make sure you're executing this code in an appropriate context:
If you're still encountering issues, you may want to check the stack trace of the exception to find out the exact line of code where the exception is being thrown. This could provide more insights into the source of the problem.