Home | Forums | Contact | Search | Syndication  
 
 [login] [create account]   Tuesday, July 1, 2025 
 
slxdeveloper.com Community Forums  
   
The Forums on slxdeveloper.com are now retired. The forum archive will remain available for the time being. Thank you for your participation on slxdeveloper.com!
 Web Forums - SalesLogix Web Platform & Application Architect
Forum to discuss the use of the SalesLogix Web Platform, Client and Customer Portals, and the Application Architect (For version 7.2 and higher only). View the code of conduct for posting guidelines.
Forums RSS Feed


 Back to Forum List | Back to SalesLogix Web Platform & Application Architect | New ThreadView:  Search:  
 Author  Thread: OnBeforeDelete script
Ronnie Martin
Posts: 26
 
OnBeforeDelete scriptYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 22 Feb 10 8:41 AM
When i run this exact code from the OnAfterInsert section it works fine. When I run this code in the OnBeforeDelete script I get the following error message. "Error: Sys.InvalidOperationException: Cannot call get_statusCode when responseAvailable is false."

Any ideas why it works in one place but not the other?

#region Usings
using System;
using Sage.Entity.Interfaces;
using Sage.Form.Interfaces;
using NHibernate;
using Sage.SalesLogix.API;
using System.Data.OleDb;
using Sage.Form;
#endregion Usings

namespace Sage.BusinessRules.CodeSnippets
{
public static partial class OpportunityProductJobBusinessRules
{
public static void OnBeforeDeleteStep( IOpportunityProductJob opportunityproductjob, ISession session)
{
string sql;
string strJobCodes = "";
Sage.Entity.Interfaces.IOpportunityJob myOppJob = opportunityproductjob.OpportunityJob;
Sage.Entity.Interfaces.IOpportunity myOpp = opportunityproductjob.OpportunityJob.Opportunity;
Sage.Platform.Data.IDataService dataService = Sage.Platform.Application.ApplicationContext.Current.Services.Get();

OleDbConnection conn = (OleDbConnection)dataService.GetConnection();

try { conn.Open(); }
catch { return; }

sql = "Select p.JobCode " +
"From sysdba.PRODUCT p join sysdba.opportunity_product op on p.productID = op.productID " +
"join sysdba.C_OPTYPRODJOB ojp on op.oppproductid = ojp.optyprodid " +
"where optyjobid ='" + myOppJob.Id.ToString() + "' order by p.JobCode";


System.Data.OleDb.OleDbDataReader dr;
System.Data.OleDb.OleDbCommand cm = new System.Data.OleDb.OleDbCommand();


try
{
cm.Connection = conn;
cm.CommandText = sql.ToString();
dr = cm.ExecuteReader();

while(dr.Read())
{
if(strJobCodes == "")
{
strJobCodes = dr["JobCode"].ToString();
}
else
{
if(dr["JobCode"] != DBNull.Value)
{
strJobCodes = strJobCodes + " , " + dr["JobCode"].ToString();
}
}

}

cm.CommandText = "UPDATE C_OptyJob " +
"SET JobCodes = '" + strJobCodes.ToString() + "' " +
"WHERE C_OptyJobID = '" + myOppJob.Id.ToString() + "'";

cm.ExecuteNonQuery();

conn.Close();

}
catch { throw; }

}
}
}


Thanks,
Ronnie
[Reply][Quote]
Nick Hollis
Posts: 549
Top 10 forum poster: 549 posts
 
Re: OnBeforeDelete scriptYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 23 Feb 10 11:15 AM
I have had problems with delete events before....I think i ended putting the code on the form to call before the delete is called. Not the best way of doing it but sometimes you have to do these things in 7.5!

The error suggests the code is timing out. Maybe a locking issue? Try stepping through the code, putting a breakpoint on the .DELETE() that you are calling.

Or put your code in a business rule, and call that before you call the delete. At least that way you are "kind of" sticking to keeping the logic out of the page

Thanks,
Nick

[Reply][Quote]
 Page 1 of 1 
  You can subscribe to receive a daily forum digest in your user profile. View the site code of conduct for posting guidelines.

   Forum RSS Feed - Subscribe to the forum RSS feed to keep on top of the latest forum activity!
 

 
 slxdeveloper.com is brought to you courtesy of Ryan Farley & Customer FX Corporation.
 This site, and all contents herein, are Copyright © 2025 Customer FX Corporation. The information and opinions expressed here are not endorsed by Sage Software.

code of conduct | Subscribe to the slxdeveloper.com Latest Article RSS feed
   
 
page cache (param): 7/1/2025 12:48:53 AM