Home | Forums | Contact | Search | Syndication  
 
 [login] [create account]   Saturday, June 28, 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: Retrieve AccountManager from Account for custom child entity OnLoadStep
Chad Morton
Posts: 8
 
Retrieve AccountManager from Account for custom child entity OnLoadStepYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 12 Jan 12 4:29 PM
fiogf49gjkf0d

Hi All,


I have a custom entry form for an entity that is a child of account. I would like to pre-populate a user lookup control with the account manager from the Account. I am trying to do this in a Code Snippet Action in the OnLoadStep event. I cannot however access the AccountManager from the parent entity. Am I even close, or is there another approach that I should be looking at.


 


Thanks ~ Chad



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

namespace Sage.BusinessRules.CodeSnippets
{
    public static partial class SCNSalesBoardEntryEventHandlers
    {
        public static void OnLoad1Step( ISCNSalesBoardEntry form,  EventArgs args)
        {
            // TODO: Complete business rule implementation
           
            IAccount account = form.WorkItem.Services.Get<Sage.Platform.Application.IEntityContextService>().GetEntity() as IAccount;
            form.SalesBoardPeriod.DateTimeValue = DateTime.Now;
            form.QFSLXUser.LookupResultValue = account.AccountManager;        
        }
    }
}


 

[Reply][Quote]
Mike LaSpina
Posts: 116
 
Re: Retrieve AccountManager from Account for custom child entity OnLoadStepYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 12 Jan 12 5:05 PM
fiogf49gjkf0d

You want to assign the entity property - not the form controls.  Use the bindingsource.cuurect to grab the current entity and then set the proporty of the entity to the AccountManager from the account.

[Reply][Quote]
Chad Morton
Posts: 8
 
Re: Retrieve AccountManager from Account for custom child entity OnLoadStepYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 13 Jan 12 8:53 AM
fiogf49gjkf0d

Thanks for the response Mike. Forgive me, but I'm still struggling with this. I now have the following, but when I build I receive the error : 


Keyword 'this' is not valid in a static property, static method, or static field initializer. I'm still learning. Thanks  ~Chad


 


public static void OnLoadSalesBoardDefaultsStep( ISCNSalesBoardEntry form,  EventArgs args)

        {

Sage.Entity.Interfaces.ISCNSalesBoard salesboard = this.BindingSource.Current as Sage.Entity.Interfaces.ISCNSalesBoard;

IAccount account = form.WorkItem.Services.Get<Sage.Platform.Application.IEntityContextService>().GetEntity() as IAccount;

form.SalesBoardPeriod.DateTimeValue = DateTime.Now;

salesboard.SalesPerson1UserID = account.AccountManager.ToString();

        }


 


 

[Reply][Quote]
Ryan Farley
Posts: 2265
slxdeveloper.com Site Administrator
Top 10 forum poster: 2265 posts
 
Re: Retrieve AccountManager from Account for custom child entity OnLoadStepYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 13 Jan 12 9:28 AM
fiogf49gjkf0d

From a Code Snippet Action you still need to use the EntityContextService (See http://customerfx.com/pages/crmdeveloper/2009/04/08/accessing-the-current-parent-entity-from-a-code-snippet-action.aspx) since BindingSource.Current is only available to C# Snippet Actions since they reside on the page itself.


Also, doing account.AccountManager.ToString() might not get you what you're after. Instead either use account.AccountManager.Id.ToString() or create an object relationship on SalesBoard to User and then set the account.AccountManager to that object property.

[Reply][Quote]
Mike LaSpina
Posts: 116
 
Re: Retrieve AccountManager from Account for custom child entity OnLoadStepYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 13 Jan 12 11:39 AM
fiogf49gjkf0d

Since you're in a Code Snippet item rather than a C# Snippet item, change


    this.BindingSource.Current as Sage.Entity.Interfaces.ISCNSalesBoard;


to


    form.CurrentEntity as Sage.Entity.Interfaces.ISCNSalesBoard;

[Reply][Quote]
Chad Morton
Posts: 8
 
Re: Retrieve AccountManager from Account for custom child entity OnLoadStepYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 13 Jan 12 3:46 PM
fiogf49gjkf0d

Works like a champ! Thank you very much.

[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): 6/28/2025 11:31:26 AM