Home | Forums | Contact | Search | Syndication  
 
 [login] [create account]   Sunday, February 23, 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: How to write common Business rule
Prathima
Posts: 32
 
How to write common Business ruleYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 29 May 08 12:07 AM
Hi,

I want to write a functionality on change of Account type,Owner has to be changed accordingly.
To get the owner I have to do multiple steps based on the logged in user.This is a common functionlaity I want this in two places.AccountDetails.ascx and InsertContact.ascx.So want to write a common Businessrule.Where and How can I write this.

Thanks,
Prathima
[Reply][Quote]
Nick Hollis
Posts: 549
Top 10 forum poster: 549 posts
 
Re: How to write common Business ruleYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 29 May 08 3:20 AM
Hi,

Does the user have to change the Owner, or will the system set the owner itself?

If the system will set the owner itself, just right click the Account Type property in App Architect, add new After Change Event. Then write your code here (i.e. set the Owner according to your required logic). The key here is to make sure that the Account Type picklist on both the screens automatically post back so the event can fire - just set the Onchange action to "Refresh Data" on the Account Type picklist. This will cause the necessary post back you require....

If you need the user to change the Owner, some more work is required...

Thanks,
Nick
[Reply][Quote]
Prathima
Posts: 32
 
Re: How to write common Business ruleYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 29 May 08 4:38 AM
Hi,

Thanks for the reply.
I want when the user changes AcctType, Owner has to be dynamically set to the owner field.
Question is Do I need to write the code in the both the forms..?
B'coz I have a multiple level checks to get the owner for the Acct type based on the logged in user.
Which means If the user belongs to first group I have to get the owner from Table 1, If the user belongs to Second group I have to get the owner from Table 2.First I need to verify the logged in user belongs to which group and accordingly write the steps. So I need to write business rules to do this.Where and How will I do this..?

Also, I don't want to repeat the code in both the forms.Is their a way to write a common code and use it in both the places just by passing Acct type...?

I tried creating a class library project from visual studio and added the logic to get the owner type.And then refrenced this project in the
C:\Documents and Settings\All Users\Application Data\Sage\Platform\Configuration\Global\codesnippets.xml
I tried to access this class from the Acct type change C# snippet action.
But I am not able to access this namespace.How can I do this..?

Also, I am not able to open a connection from my class library project.
I have used the following code:
Sage.Platform.Data.IDataService dataService = Sage.Platform.Application.ApplicationContext.Current.Services.Get();
string s= dataService.GetConnectionString();
dataService.Open();
I am getting "object refrence not set to an instance" error.

Any help on this would be appreciated.

Thanks,
Prathima



[Reply][Quote]
Nick Hollis
Posts: 549
Top 10 forum poster: 549 posts
 
Re: How to write common Business ruleYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 29 May 08 4:48 AM
Hi,

The code only needs to be written on the onchange event of the Account Type property, so you could change the property on a million different screens and the code only has to be in that one place. The only thing you must do on each form is cause the Account Type picklist to cause a post back so the code can run.

Everything you need to do can be done in the ONchange event for the property. I.e. get the current user, obtain whatever you need to etc. For this you should work with the entity model, you dont need to create an external class file and use a custom connection.i.e.

Sage.Platform.Security.IUserService userService = Sage.Platform.Application.ApplicationContext.Current.Services.Get();

Gets the current user entity for you to work with....

Just to reiterate, when I say onchange event for the Account Type property, I do not mean on onchange event for the actual picklist on the form, but the actual Type property of the Account entity - this is done outside of forms etc, by expanding Properties under Account, and right clicking the Appropriate one.

For your reference, to get the current connection string:

Sage.Platform.Data.IDataService service = Sage.Platform.Application.ApplicationContext.Current.Services.Get();
string connection = service.GetConnectionString();

System.Data.OleDb.OleDbConnection con = new System.Data.OleDb.OleDbConnection(connection);
con.Open();

Add a reference to System.Data in App Architect though so the Application has the necessary references to use this namespace.

Thanks,
Nick
[Reply][Quote]
Prathima
Posts: 32
 
Re: How to write common Business ruleYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 29 May 08 5:14 AM
Thanks again for the reply.
Yeah I saw on the onchange event of the Account Type property!.
Can you pl give me the sample code to get the current user, current user entity.

I forgot to paste the the following code:
System.Data.OleDb.OleDbConnection con = new System.Data.OleDb.OleDbConnection(connection);
I have used OleDbConnection to get the connection.

Thanks,
Prathima

[Reply][Quote]
Nick Hollis
Posts: 549
Top 10 forum poster: 549 posts
 
Re: How to write common Business ruleYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 29 May 08 5:24 AM
I already have pasted it - the line in my comment above. Look at the various properties of Userservice using intellisense in VS...
[Reply][Quote]
Prathima
Posts: 32
 
Re: How to write common Business ruleYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 02 Jun 08 5:46 AM
Hmm..
I was busy with QA issues.Could not concentrate on this..
Have got the business rule. Now I want to assign the return value to the Division TextBox.
How can I find this Division control on AccountDetails and assign..?

Thanks,
Prathima
[Reply][Quote]
Nick Hollis
Posts: 549
Top 10 forum poster: 549 posts
 
Re: How to write common Business ruleYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 02 Jun 08 6:17 AM
Business rules can update entity values, not physically interact with controls on a screen - they are "Business Logic" separate from the "presentation" logic. In your business rule, if you set the value of the Account.Division entity to the required value, your control on the screen will automatically get this value, as the control is bound to the Account.Division property. Make sense??
[Reply][Quote]
Prathima
Posts: 32
 
Re: How to write common Business ruleYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 02 Jun 08 6:24 AM
Thanks for the reply,
Exactly I have also followed the same thing.
I have assigned Account.Division = returned value;
But it is not reflecting on the screen.
I have build the AA and deployed.Anything else do I need to do..?


Prathima
[Reply][Quote]
Nick Hollis
Posts: 549
Top 10 forum poster: 549 posts
 
Re: How to write common Business ruleYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 02 Jun 08 7:23 AM
Is the business rule being fired (and causing a postback)? There is nothing else to this...

Try refreshing the page after the business rule fires.

Also, try debugging the website, and stepping through the code and make sure (for certain) that the business rule is running and the Account.Division is being appropriately set.
[Reply][Quote]
Prathima
Posts: 32
 
Re: How to write common Business ruleYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 03 Jun 08 4:52 AM
Hi,

AA has written method for typeChanged event : private void OnAfterTypeChanged(EventArgs args){} in Account.cs. But this is not firing. Breakpoint is not hit whe I change the type picklist.But refreshing is happening.

protected void pklType_ChangeAction(object sender, EventArgs e) {
Sage.Platform.WebPortal.Services.IPanelRefreshService refresher = PageWorkItem.Services.Get();
if (refresher != null) {
refresher.RefreshAll();
}
else {
Response.Redirect(Request.Url.ToString());
}
}

[Reply][Quote]
Prathima
Posts: 32
 
Re: How to write common Business ruleYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 04 Jun 08 12:57 AM
I have set PklType OnChange Action property to refreshData.

[Reply][Quote]
Nick Hollis
Posts: 549
Top 10 forum poster: 549 posts
 
Re: How to write common Business ruleYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 04 Jun 08 3:06 AM
Hi Prathima,

Can you let me the know the exact steps taken when creating the onchange event for the property? Literally every step - it sounds like something is missing here.

Thanks,
Nick
[Reply][Quote]
Prathima
Posts: 32
 
Re: How to write common Business ruleYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 04 Jun 08 4:01 AM
Hi,

1.Right click on the property type under Account entity and add New After Change event.
2.Give the method name and click on Add link.
3.Select C# snippet code and click on OK.
4.Click on Edit code snippet.
5.To make it simple I have just give account.Division = "Success";[All other logic I have removed for now].
6.Build snippet library.
7.In the AccountDetail form for the "Type" pick list, set the OnChange Action property to refreshdata.
8.Build Web platform
9.Deploy and Run.

I have opened the website in the VS and included C# snippet code project to the solution.Used the breakpoint in the following places: Account.cs for the "type" property and event, C# snippet project for the method I have added and AccountDetails.ascx on the onTypeChange() event.
When I change a type from the UI, breakpoint is neigther hit in the C# snippet project nor in Account.cs file where a call to C# snippet project[Dynamic Library] is there.

Thanks in advance,
Prathima
[Reply][Quote]
Nick Hollis
Posts: 549
Top 10 forum poster: 549 posts
 
Re: How to write common Business ruleYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 04 Jun 08 5:38 AM
For 7) set the change action of the picklist to C# Snippet, instead of refresh data. In the snippet hook into the current entity and call entity.Save(). This should trigger your change event.

ie.

Sage.Entity.Interfaces.IAccount account = this.BindingSource.Current as Sage.Entity.Interfaces.IAccount;
account.Save();

Nick
[Reply][Quote]
Prathima
Posts: 32
 
Re: How to write common Business ruleYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 04 Jun 08 8:23 AM
Nick,

Thanks for the suggestion.
Now it is triggering the change event and setting the value to the account.Division property.
But after that when the page loads I don't see the valus in the control.
I am getting the following error in the output window of VS.
----
A first chance exception of type 'System.IO.EndOfStreamException' occurred in mscorlib.dll
Microsoft JScript runtime error: Sys.InvalidOperationException: Cannot call get_statusCode when responseAvailable is false.
Microsoft JScript runtime error: Sys.InvalidOperationException: Cannot call get_statusCode when responseAvailable is false.
---------------

Thanks,
Prathima
[Reply][Quote]
Nick Hollis
Posts: 549
Top 10 forum poster: 549 posts
 
Re: How to write common Business ruleYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 04 Jun 08 8:48 AM
After calling account.Save() try:

Sage.Platform.WebPortal.Services.IPanelRefreshService refresher = PageWorkItem.Services.Get();
if (refresher != null) {
refresher.RefreshAll();
}

I do not know why the control doesnt show the new property, after all the page has had the postback it needs.

I have no idea what those errors mean, sorry!!
[Reply][Quote]
Prathima
Posts: 32
 
Re: How to write common Business ruleYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 04 Jun 08 11:13 PM
Thanks a lot Nick.
After calling refresh I am able to see the value in the control also.

Thanks again,
Prathima
[Reply][Quote]
Prathima
Posts: 32
 
Re: How to write common Business ruleYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 05 Jun 08 12:52 AM
Hi Nick,

So far I was doing it from Account details screen.
Now I am trying type change from New-Account/Contact which is under Contact entity.
From New-Account/Contact screen, it is not triggring the OnAfterTypeChanged() changed event.

I am calling only PanelrefreshService b'coz currently I am in contact entity,if call account.Save() it throws an error.
I tried calling contact.account.Save(), eventhen it throws error saying account cannot be saved without accountName.


Thanks,
Prathima
[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): 2/23/2025 10:56:39 AM