Login / Register  search  syndication

          Ryan Farley's Blog

Ryan Farley on .NET Development with a focus on CRM Development for SalesLogix

Error Opening InsertOpportunity.aspx in SalesLogix 7.2 Web

I posted this a while back in the SalesLogix Business Partner newsgroups, but it has recently just helped a few others who came across it there, so I thought it would be a worthwhile public post. Not everyone will get the error mentioned in this post, but if you are then this should help. This post also describes my troubleshooting process to locate this issue and determine the fix for it.

I have a customer who could not bring up the Insert New Opportunity Screen. After stepping through things with VS I determined that I was getting an error in the GetOppProductDefaults business rule on the Opportunity entity. The GetOppProductDefaults method looks like this (as seen through reflector):

public static void GetOppProductDefaults(IOpportunity opportunity)
{
string commonOption = ApplicationContext.Current.Services.Get<IUserOptionsService>().GetCommonOption("Products", "OpportunityDefaults");
if (commonOption != "")
{
commonOption = commonOption.Substring(commonOption.IndexOf("<rs:data>")).Replace("rs:data>", "rsdata>").Replace("z:row", "zrow").Replace("</xml>", "");
XmlDocument document = new XmlDocument();
try
{
document.LoadXml(commonOption);
foreach (XmlNode node in document.SelectSingleNode("rsdata").ChildNodes)
{
if (node.Attributes["PRODUCTID"].Value != null)
{
IOpportunityProduct item = EntityFactory.Create<IOpportunityProduct>();
item.Opportunity = opportunity;
item.Product = EntityFactory.GetById<IProduct>(node.Attributes["PRODUCTID"].Value);
item.Sort = new int?(Convert.ToInt32(node.Attributes["SORT"].Value));
item.Program = node.Attributes["PRICELEVEL"].Value;
item.Price = new decimal?(Convert.ToDecimal(node.Attributes["PRICE"].Value));
item.Discount = new double?(Convert.ToDouble(node.Attributes["DISCOUNT"].Value));
item.Quantity = new double?(Convert.ToDouble(node.Attributes["QUANTITY"].Value));
item.ExtendedPrice = new decimal?(Convert.ToDecimal(node.Attributes["EXTENDED"].Value));
opportunity.Products.Add(item);
}
}
}
catch (Exception)
{
throw new Exception("Invalid xml for default Opportunity Products");
}
}
}

The stack trace from the exception showed the following:

   at System.String.InternalSubStringWithChecks(Int32 startIndex, Int32 length, Boolean fAlwaysCopy)
at System.String.Substring(Int32 startIndex)
at Sage.SalesLogix.Opportunity.Rules.GetOppProductDefaults(IOpportunity opportunity)
at Sage.SalesLogix.Opportunity.Rules.CheckOppAccount(IOpportunity opportunity, Boolean& result)
at (Object )
at Sage.Platform.DynamicMethod.DynamicMethodLibrary.Execute(String methodName, Object[] args)

You'll notice that the exception was thrown from the attempt to use Substring on a string within the GetOppProductDefaults method. The Substring is used to get only the XML between the <rs:data></rs:data> tags from the serialized XML from the Recordset stored there, ignoring the schema data from the beginning section of the XML. So, I looked and this is what this customer has stored there for *all* users for the Products in the OpportunityDefaults user option:

<xml xmlns:z="#RowsetSchema" xmlns:rs="urn:schemas-microsoft-com:rowset" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:s="uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882">
<s:Schema id="RowsetSchema">
<s:ElementType name="row" content="eltOnly" rs:updatable="true">
<s:AttributeType name="SORT" rs:number="1" rs:write="true">
<s:datatype dt:type="int" dt:maxLength="4" rs:precision="0"
rs:fixedlength="true" rs:maybenull="false"/>
</s:AttributeType>
<s:AttributeType name="PRODUCTID" rs:number="2" rs:write="true">
<s:datatype dt:type="string" rs:dbtype="str" dt:maxLength="12"
rs:precision="0" rs:maybenull="false"/>
</s:AttributeType>
<s:AttributeType name="KEYFIELDID" rs:number="3" rs:write="true">
<s:datatype dt:type="string" rs:dbtype="str" dt:maxLength="16"
rs:precision="0" rs:maybenull="false"/>
</s:AttributeType>
<s:AttributeType name="PRODUCT" rs:number="4" rs:write="true">
<s:datatype dt:type="string" rs:dbtype="str" dt:maxLength="64"
rs:precision="0" rs:maybenull="false"/>
</s:AttributeType>
<s:AttributeType name="FAMILY" rs:number="5" rs:write="true">
<s:datatype dt:type="string" rs:dbtype="str" dt:maxLength="64"
rs:precision="0" rs:maybenull="false"/>
</s:AttributeType>
<s:AttributeType name="PRICELEVEL" rs:number="6" rs:write="true">
<s:datatype dt:type="string" rs:dbtype="str" dt:maxLength="32"
rs:precision="0" rs:maybenull="false"/>
</s:AttributeType>
<s:AttributeType name="PRICE" rs:number="7" rs:write="true">
<s:datatype dt:type="number" rs:dbtype="currency" dt:maxLength="8"
rs:precision="0" rs:fixedlength="true" rs:maybenull="false"/>
</s:AttributeType>
<s:AttributeType name="DISCOUNT" rs:number="8" rs:write="true">
<s:datatype dt:type="float" dt:maxLength="8" rs:precision="0"
rs:fixedlength="true" rs:maybenull="false"/>
</s:AttributeType>
<s:AttributeType name="ADJPRICE" rs:number="9" rs:write="true">
<s:datatype dt:type="number" rs:dbtype="currency" dt:maxLength="8"
rs:precision="0" rs:fixedlength="true" rs:maybenull="false"/>
</s:AttributeType>
<s:AttributeType name="PRICELOCAL" rs:number="10" rs:write="true">
<s:datatype dt:type="number" rs:dbtype="currency" dt:maxLength="8"
rs:precision="0" rs:fixedlength="true" rs:maybenull="false"/>
</s:AttributeType>
<s:AttributeType name="QUANTITY" rs:number="11" rs:write="true">
<s:datatype dt:type="float" dt:maxLength="8" rs:precision="0"
rs:fixedlength="true" rs:maybenull="false"/>
</s:AttributeType>
<s:AttributeType name="EXTENDED" rs:number="12" rs:write="true">
<s:datatype dt:type="number" rs:dbtype="currency" dt:maxLength="8"
rs:precision="0" rs:fixedlength="true" rs:maybenull="false"/>
</s:AttributeType>
<s:AttributeType name="EXTENDEDLOCAL" rs:number="13"
rs:write="true">
<s:datatype dt:type="number" rs:dbtype="currency" dt:maxLength="8"
rs:precision="0" rs:fixedlength="true" rs:maybenull="false"/>
</s:AttributeType>
<s:extends type="rs:rowbase"/>
</s:ElementType>
</s:Schema>

</xml>

There is no <rs:data> section in this XML, so obviously, that is why the use of Substring is failing, because the IndexOf is returning an invalid integer for a start position. Normally, in any other system I've checked so far, this XML is completely blank for users that have never set any defaults. For a user that goes into the dialog to set the defaults and clicks OK without selecting any default products they will have the XML, but an empty <rs:data> section. Empty is OK, because at least it exists and the code above will not fail.

So, I have no idea what caused the XML to get saved this way in the first place. I will continue to look for this in other systems, but I wanted to mention all this here in case others run into this. This is all fixed by having these users simply go into the Opportunity Defaults dialog (in the fat client) and just clicking OK. This will cause the empty <rs:data> section to be added to the XML for the serialized recordset and then all wil work fine.

I was originally going to suggest that the code for the GetOppProductDefaults be changed to check the IndexOf the "<rd:data>" section frst before proceeding to get the Substring. This certainly would have saved me some headache since the code would not have completely crapped out for this customer - but I have no idea how this got stored this way for this customer in the first place, so no telling how common this scenario would be. The weird thing is that the XML is like this for *all* users for my customer. This was an upgrade BTW, but so was my own internal database and it doesn't have this problem.

The Solution

For now, just have your users go to the Set Opportunity Defaults screen in the Windows client and just open and close (by clicking OK) the opportunity products default screen (they don't actually have to select any product defaults). This will cause the proper XML string to be saved for that user. Optionally, you could programatically store the corrected XML for them.

I've not checked yet to see if this business rule has been fixed for 7.5 or not.

What's This?
Bookmark and Share

About Ryan Farley

   Ryan Farley is the Director of Development for Customer FX Corporation and the creator of slxdeveloper.com.


Related Content
   SalesLogix Web Client- Working with Activities
In this webinar the user will learn to work with Activities from the Activities entity. This feature all
Posted on Mar 16, 2010 by Dale Richter to SalesLogix Training
 
   Adding an assembly reference to code files in the SalesLogix Application Architect
Often when adding custom code to SalesLogix you need to reference Assemblies that are not included by def
Posted on Mar 15, 2010 by Kris Halsrud to Kris Halsrud's Blog
 
   SalesLogix Web Client- Marketing Campaigns Part I [Video]
In this video webinar the Marketing Professional will learn how to create a New Marketing Campaign in Sal
Posted on Mar 15, 2010 by Dale Richter to SalesLogix Training
 
   Launching a report from a button in the SalesLogix web client
Starting in SalesLogix 7.5.1, Sage released an undocumented Reporting enhancement that allowed for intera
Posted on Mar 12, 2010 by Kris Halsrud to Kris Halsrud's Blog
 
   Hiding Opportunities in the SalesLogix web client
Occasionally we have clients who do not use the Opportunity components of the SalesLogix web client. 
Posted on Mar 10, 2010 by Kris Halsrud to Kris Halsrud's Blog
 
Comments

 

juliej said:

hi - this seems to still be a problem with v7.5.1, do you know of any other fix for this as when i change the web user to a lan user in order to set the default opp the default opp is not actually opening!!  therefore I am unable to fix the problem, any ideas?  thanks, your help is really appreciated.

julie

July 23, 2009 6:34 AM

Leave a Comment

(required)  
(optional)
(required)  
Add
All contents Copyright © 2010 Customer FX Corporation
Customer FX Corporation
2324 University Avenue West, Suite 115
Saint Paul, Minnesota 55114
Tel: 800.728.5783

  Follow @CustomerFX on twitter
Follow the best news, tips, and articles
  Subscribe to Customer FX on youtube
Watch SalesLogix tutorial videos from Customer FX
Login / Register