Policy Schedules B1,B2 - Sample code needed

Discussions related to custom development with Select.
Post Reply
PeterKelly
Posts: 92
Joined: Tue Feb 04, 2014 3:34 pm

Policy Schedules B1,B2 - Sample code needed

Post by PeterKelly »

I'm trying to accomplish the following in code and would appreciate any sample code:

Click Start Policy
Merge - OK
Click Import Exceptions or Subordinate Matters
Select all items - Click ok




Thanks,
Peter
Graham Campbell
Posts: 61
Joined: Fri Jul 01, 2011 10:06 am
Location: Raleigh, North Carolina
Contact:

Re: Policy Schedules B1,B2 - Sample code needed

Post by Graham Campbell »

This is how to do the Start Policy - Merge programmatically:

Code: Select all

IOrderItem policy = /* Some logic to get the policy you want to merge into */

if (policy.GetType().GetMethod("MergeExceptions", BindingFlags.Public | BindingFlags.Instance) != null)
{
    using (SoftPro.Select.Client.Lookups.LookupSuppressionBlock.Suppress())
    {
        policy.Invoke("MergeExceptions");
    }
}

My initial impression of the import dialog is that it is simply copying one tree of data into another tree of data, so you will likely want to walk the trees of objects and insert them appropriate, potentially through a recursive function. However, this code base does not translate cleanly to your use case since the current implementation is tied heavily to the UI. I may need to refer you to a developer familiar with the area if you need to replicate the behavior precisely.

Below is how to create a single exception and copy the data from another phrase into it:

Code: Select all

IOrderItem sourceException = /* Some logic to get the source exception */
IOrderItem policy = /* Some logic to get the policy you want to import into */

IOrderItem newException = policy.Order.CreateNew("Exception");

using (SoftPro.Select.Client.Lookups.LookupSuppressionBlock.Suppress())
{
    newException = (IOrderItem)sourceException.Invoke("CreateCopy", newException, false, false);
    sourceException.Invoke("CopyIncludeOnValues", newException);
}

IList destinationExceptions = (IList)policy["Exceptions"];
destinationExceptions.Add(newException);
Graham Campbell
SoftPro Software Engineer
PeterKelly
Posts: 92
Joined: Tue Feb 04, 2014 3:34 pm

Re: Policy Schedules B1,B2 - Sample code needed

Post by PeterKelly »

Thanks for the code Graham!

I can get the policy. How do I get the exceptions to import as is done in the UI?

We do have a tight deadline to load test Cameron for North Carolina and we were given the workflow to reproduce exactly so if you can forward this request to the developer that is familiar with this area that would be great.

Thanks,
Peter
Melissa McBerkowitz
Posts: 91
Joined: Wed Sep 10, 2008 3:33 pm
Location: Raleigh, NC
Contact:

Re: Policy Schedules B1,B2 - Sample code needed

Post by Melissa McBerkowitz »

Peter, I don't think this is a valid use case. When the user clicks Start Policy, it brings all exceptions from the commitment over to the policy. If you then used the Import feature to select all, you'd bring duplicates of each of those exceptions over to the policy. The Start Policy use case is the typical one, and users would only click "Import" for one-off exceptions that need to be pulled from another policy.

Graham can still help with the code, but I'd suggest focusing on the Start Policy piece.
Melissa McBerkowitz
VP of Product Strategy, SoftPro
Graham Campbell
Posts: 61
Joined: Fri Jul 01, 2011 10:06 am
Location: Raleigh, North Carolina
Contact:

Re: Policy Schedules B1,B2 - Sample code needed

Post by Graham Campbell »

Given Melissa's response, I will wait for clarification on what is required here. I agree that the use case being described would generate two copies of each exception, which is likely not desired.
Graham Campbell
SoftPro Software Engineer
PeterKelly
Posts: 92
Joined: Tue Feb 04, 2014 3:34 pm

Re: Policy Schedules B1,B2 - Sample code needed

Post by PeterKelly »

Ok, we got clarification on the use cases which changes things significantly and avoids the duplicate exceptions.


1) Go to Commitment Schedule B1,B2

2) Double Click Exceptions-> Tax58

3) Replace "Taxes or assessments for the year _____, and subsequent years, not yet due or payable." with "Taxes or assessments for the year 2015, and subsequent years, not yet due or payable." and Click OK

4) Go to Policy Schedules B1,B2

5) Click Start Policy, select Overwrite and then click OK

Thanks,
Peter
PeterKelly
Posts: 92
Joined: Tue Feb 04, 2014 3:34 pm

Re: Policy Schedules B1,B2 - Sample code needed

Post by PeterKelly »

I was already given the code for steps 4 and 5. Do I just replace "MergeExceptions" with "OverwriteExceptions"?



IOrderItem policy = /* Some logic to get the policy you want to merge into */

if (policy.GetType().GetMethod("MergeExceptions", BindingFlags.Public | BindingFlags.Instance) != null)
{
using (SoftPro.Select.Client.Lookups.LookupSuppressionBlock.Suppress())
{
policy.Invoke("MergeExceptions");
}
}
Graham Campbell
Posts: 61
Joined: Fri Jul 01, 2011 10:06 am
Location: Raleigh, North Carolina
Contact:

Re: Policy Schedules B1,B2 - Sample code needed

Post by Graham Campbell »

When the Overwrite was created, the developers simply cleared the list and then invoked the Append functionality.

As such, this is how we invoke an Overwrite:

Code: Select all

IOrderItem policy = /* Some logic to get the policy you want to merge into */

using (SoftPro.Select.Client.Lookups.LookupSuppressionBlock.Suppress())
{
    var existingExceptions = (IList)policy["Exceptions"];
    existingExceptions.Clear();

    policy.Invoke("ImportExceptions");
}
I think that this method existed in the original implementation, so you likely don't need to check for the method existence. However, it wouldn't hurt to check if you prefer to.
Graham Campbell
SoftPro Software Engineer
PeterKelly
Posts: 92
Joined: Tue Feb 04, 2014 3:34 pm

Re: Policy Schedules B1,B2 - Sample code needed

Post by PeterKelly »

That worked. Thanks for your help!
Post Reply