Exception trying to set up a field value

Discussions related to custom development with Select.
merak.marey
Posts: 14
Joined: Fri Oct 30, 2020 10:41 am

Exception trying to set up a field value

Post by merak.marey »

Hi
I'm receiving an exception trying to a set G.09.01 section fee. (aggregated adjustment)

Here's an excerpt of a log for this exception

2021-02-18 16:18:23,721 [622] ERROR CDFeesMerger [(null)] - Go for Order:111661-004946 f= 1004. t= default
2021-02-18 16:18:24,174 [622] ERROR CDFeesMerger [(null)] - Go for Order:111661-004946 f= 1007. t= default
2021-02-18 16:18:25,440 [622] ERROR CDFeesMerger [(null)] - Setting adjustment in order..
2021-02-18 16:18:25,596 [622] ERROR CDFeesMerger [(null)] - General exception: Cannot access member.
2021-02-18 16:18:25,643 [622] ERROR CDFeesMerger [(null)] - -StackTrace: at SoftPro.EntityModel.Field`1.set_Value(T value)
at EscrowDetailPayor.set_ProcessAs(ProcessAs )
at CallSite.Target(Closure , CallSite , Object , ProcessAs )
at System.Dynamic.UpdateDelegates.UpdateAndExecute2[T0,T1,TRet](CallSite site, T0 arg0, T1 arg1)
at EncompassToSoftProMerge.FeeMerger.Merge(EncompassJsonModel EncompassObject, IOrder SPOrder) in C:\workspaces\TitleFeeCollaboration.Prod\CDFees\Helpers\FeeMerger.cs:line 1422


Here's the code:

var AdjustmentOrderLine = (dynamic)((IEnumerable)Lines).Cast<dynamic>()
.Where(p => p.Description == "Aggregate Adjustment" || (dynamic)((IEnumerable)p.Charges).Cast<dynamic>()
.Where(c => c.Description == "Aggregate Adjustment").ToList().Count() > 0).ToList().FirstOrDefault();
if (AdjustmentOrderLine != null)
{
AdjustmentOrderLine.Charges.Clear();
if (EncompassObject.agregateAdjustment != 0)
{
_log.Error("Setting adjustment in order..");
AdjustmentOrderLine.Charges[0].BuyerPaidAtClosing = EncompassObject.agregateAdjustment; // HERE - 1422
//AdjustmentOrderLine.Charges[0].Contact = GetContact(Order, "L");
//AdjustmentOrderLine.Charges[0].Payors[0].Contact = GetContact(Order, "B");
AdjustmentOrderLine.Charges[0].Payees[0].IsDeducted= false;
AdjustmentOrderLine.Charges[0].Payors[0].ProcessAs = SoftPro.OrderTracking.Client.Orders.ProcessAs.ReduceFunds;
}
}
else
{
_log.Error("Failed to locate Aggregate Adjustment Line");
return false;
}
BobRichards
Posts: 1376
Joined: Wed Jan 15, 2014 3:50 pm
Location: Raleigh, NC
Contact:

Re: Exception trying to set up a field value

Post by BobRichards »

There does not appear to be an obvious issue. I would like to rule out a couple common problems before we continue. Please review your code.
  • The order is opened as writable :

    Code: Select all

    IOrderStore os = ...
    IOrder order = os.OpenOrder(... , OrderEditMode.ReadWrite);
  • It is not a type issue coming from your method EncompassObject.agregateAdjustment. Replace your method with a constant.

    Code: Select all

    AdjustmentOrderLine.Charges[0].BuyerPaidAtClosing = 42m;
  • It is not an issue with dynamics. Sometimes the DLR has issues resolving objects. Yes - I doubt this is the case but please make sure. (This code is from memory so it may not be perfect.)

    Code: Select all

    IOrderItem line = (IOrderItem)AdjustmentOrderLine;
    IList charges = (IList)line.GetProperty("Charges");
    IOrderItem charge = (IOrderItem)charges[0];
    charge.SetProperty("BuyerPaidAtClosing", 42m);
    
  • With a breakpoint set on the code line that breaks, use VS to look at the charges and make sure there is at least one charge associated with "AdjustmentOrderLine".
Bob Richards, Senior Software Developer, SoftPro
merak.marey
Posts: 14
Joined: Fri Oct 30, 2020 10:41 am

Re: Exception trying to set up a field value

Post by merak.marey »

Unfortunately I have tried all the steps you mentioned and it's still not working.. Is there any way to know which engine rule denied the access to the field? Maybe that can throw some light on the reason it's a read-only field..
BobRichards
Posts: 1376
Joined: Wed Jan 15, 2014 3:50 pm
Location: Raleigh, NC
Contact:

Re: Exception trying to set up a field value

Post by BobRichards »

One more thing - can you do this operation using the Select GUI application when logged in as the same user as your API application? This is to verify the user has necessary permissions and all the steps are known.
Bob Richards, Senior Software Developer, SoftPro
merak.marey
Posts: 14
Joined: Fri Oct 30, 2020 10:41 am

Re: Exception trying to set up a field value

Post by merak.marey »

According to our Business side she can change it on the UI without any issues. One thing I have wondered. See, in my code I use a simple assignment, and in yours you use the SetProperty method.. any differences?
BobRichards
Posts: 1376
Joined: Wed Jan 15, 2014 3:50 pm
Location: Raleigh, NC
Contact:

Re: Exception trying to set up a field value

Post by BobRichards »

If you put a breakpoint at the line in question and look at its type in the Visual Studio Locals window, what it the reported type?
Bob Richards, Senior Software Developer, SoftPro
Richardrkk
Posts: 1
Joined: Wed Mar 31, 2021 11:09 am

Re: Exception trying to set up a field value

Post by Richardrkk »

Hello Bob/Merak,
Bob, is there any way you can put some code together for us that we can run to provide more insight into this issue? Pardon my interruption :)
BobRichards
Posts: 1376
Joined: Wed Jan 15, 2014 3:50 pm
Location: Raleigh, NC
Contact:

Re: Exception trying to set up a field value

Post by BobRichards »

Hey. Did anyone try what I recommended in my prior post? Analysis depends on knowing the type you are trying to modify.
Bob Richards, Senior Software Developer, SoftPro
merak.marey
Posts: 14
Joined: Fri Oct 30, 2020 10:41 am

Re: Exception trying to set up a field value

Post by merak.marey »

Hi all

Just an update on this. I have tried all Bob suggestions however I'm still getting the same error. With a breakpoint before assigning the value I did some inspection and GetIsReadOnly of the property returns true.

My main concern is there is no way to tell why. Bob and I had a meeting and he explained to me that certain reasons on why this may be read only is due some security about the internals of the SP engine.

Still, this does not solve the issue of knowing why. Its kinda hard to explain to Business that something cannot be done just because. And of course, this becomes a dead end since there is no path to follow to solve this.

So...suggestions?
BobRichards
Posts: 1376
Joined: Wed Jan 15, 2014 3:50 pm
Location: Raleigh, NC
Contact:

Re: Exception trying to set up a field value

Post by BobRichards »

I have passed your problem to the internal R&D folks. I'll let you know when I have an answer.
Bob Richards, Senior Software Developer, SoftPro
Post Reply