Home | Forums | Contact | Search | Syndication  
 
 [login] [create account]   Tuesday, June 3, 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: New to Web Development
Ronnie Martin
Posts: 26
 
New to Web DevelopmentYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 20 Apr 09 2:59 PM
I need to default the Account Manager (User selection) to the Current User on the Insert Opportunity Form. Currently it defaults to the Account Manager of the Account selected.

I am able to get the Current UserID out, but I cant figure out how to put it back into the form.

I have tried the following with no luck. I am sure I am just missing something simple. I used a "ShowMessage" right before each line to make sure I am getting the correct CurrentUserID and it shows up correctly, so I know the code is running.

form.usrUser.text = currentUserId.ToString(); <-- Does nothing
form.usrUser = currentUserId.ToString(); <-- "cannot be assigned to -- it is read only" Error on build
form.usrUser.LookupResultValue = currentUserId.ToString(); <-- Does nothing

Thanks
[Reply][Quote]
Ryan Farley
Posts: 2265
slxdeveloper.com Site Administrator
Top 10 forum poster: 2265 posts
 
Re: New to Web DevelopmentYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 20 Apr 09 5:56 PM
How are you getting the current userid? If you're using the UserService then you can also get the current user object from that.

Sage.Platform.Security.IUserService userService = form.WorkItem.Services.Get<Sage.Platform.Security.IUserService>();
form.usrUser.LookupResultValue = userService.GetUser();


Make sense?
[Reply][Quote]
Nick Hollis
Posts: 549
Top 10 forum poster: 549 posts
 
Re: New to Web DevelopmentYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 21 Apr 09 5:30 AM
Quote:
Originally posted by Ronnie Martin

I need to default the Account Manager (User selection) to the Current User on the Insert Opportunity Form. Currently it defaults to the Account Manager of the Account selected.

I am able to get the Current UserID out, but I cant figure out how to put it back into the form.

I have tried the following with no luck. I am sure I am just missing something simple. I used a "ShowMessage" right before each line to make sure I am getting the correct CurrentUserID and it shows up correctly, so I know the code is running.

form.usrUser.text = currentUserId.ToString(); <-- Does nothing
form.usrUser = currentUserId.ToString(); <-- "cannot be assigned to -- it is read only" Error on build
form.usrUser.LookupResultValue = currentUserId.ToString(); <-- Does nothing

Thanks


I would set the AccountManager at the Entity level, not the form level, something like:

//Sage.Platform.Security.IUserService userService = form.WorkItem.Services.Get();
//opp.AccountManager = (Sage.Entity.Interfaces.IUser)userService;

The form would then obviously reflect what is on the entity, so it would reflect the correct value.

As an aside, your code wouldnt work as you need to set the LookupResultsValue of the lookup - this LookupResultsValue is an "object (IUser)" so needs to be a User object (see Ryan's response above), not a string value.
[Reply][Quote]
Ronnie Martin
Posts: 26
 
Re: New to Web DevelopmentYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 21 Apr 09 9:25 AM
Thanks for the help! I am going to work on it againt today and see if I can get it work.

I am using the following to get the UserID.

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

//string currentUserId = userService.UserId;
[Reply][Quote]
Ryan Farley
Posts: 2265
slxdeveloper.com Site Administrator
Top 10 forum poster: 2265 posts
 
Re: New to Web DevelopmentYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 21 Apr 09 10:04 AM
What Nick says is spot on - if it makes sense to do it in the entity's OnCreate event then that is a better place to do it than on the form.

However, also mentioned that the LookupResultValue is expecting an object, not a string. Instead of using this:

mylookup.LookupResultValue = userService.UserId;

use this:

mylookup.LookupResultValue = userService.GetUser();

-Ryan
[Reply][Quote]
Ronnie Martin
Posts: 26
 
Re: New to Web DevelopmentYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 24 Apr 09 4:55 PM
Quote:
Originally posted by Ryan Farley


mylookup.LookupResultValue = userService.GetUser();


When I did that i got the error below when I clicked 'Build Web Platform'.

'Sage.Platform.Security.IUserService' does not contain a definition for 'GetUser'

So I tried it with "mylookup.LookupResultValue = userService.GetType();", and I didn't get a build error, but nothing happened on the Insert Opportunity Screen. I am going try the way Nick suggested. I will let you know.

Thanks
[Reply][Quote]
Ronnie Martin
Posts: 26
 
Re: New to Web DevelopmentYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 07 May 09 2:51 PM
Ryan,
Do you know why the .GetUser() is not an option for my userService object?

Do I need to include some other file in my using area?
I tried to use .GetType() but that doesn’t seem to return what I need.

I've seen other documentation using the .GetUser() but it’s not working for me.

Any advice would be much appreciated!

Thanks,
Ronnie
[Reply][Quote]
Raul A. Chavez
Posts: 1300
Top 10 forum poster: 1300 posts
 
Re: New to Web DevelopmentYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 07 May 09 3:17 PM
What type of Object is your user Service object?
It has to be an SLXUserService (or Derived object).


Try:
Sage.SalesLogix.Security.SLXUserService slxUserService = ApplicationContext.Current.Services.Get() as Sage.SalesLogix.Security.SLXUserService;
slxUserService.GetUser().Id.ToString();
[Reply][Quote]
Ronnie Martin
Posts: 26
 
Re: New to Web DevelopmentYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 07 May 09 3:34 PM
My UserService Object is defined in the following.

Sage.Platform.Security.IUserService userService = form.WorkItem.Services.Get();

I tired the code you posted, but I was unable to get it to work. I changed SalesLogix to Platform and SLXUserService to IUserService, but then I am back to where I started.
[Reply][Quote]
Mark Dykun
Posts: 297
 
Re: New to Web DevelopmentYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 08 May 09 6:10 AM
Ronnie, looking at the provided code snippets as well as yours it seems that there is a bit of secret sauce missing. It is correct to get the IUserService implemented object from the service collection but you have to specify what object to get from the service collection. Using form.WorkItem.Services.Get() would not work as the type is not specified. Use the following code;

Sage.SalesLogix.Security.SLXUserService userService =
ApplicationContext.Current.Services.Get<Sage.Platform.Security.IUserService>() as Sage.SalesLogix.Security.SLXUserService;

Sage.SalesLogix.Security.User user = userService.GetUser();

BTW, ryans code is correct

Mark
[Reply][Quote]
Matt Dockins
Posts: 159
 
Re: New to Web DevelopmentYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 28 Aug 09 7:06 PM
This new web code is SOOOO much cleaner than the old vbscript and Application Object...

So to equate this to old code:

Sage.SalesLogix.Security.SLXUserService userService =
ApplicationContext.Current.Services.Get() as Sage.SalesLogix.Security.SLXUserService;

Sage.SalesLogix.Security.User user = userService.GetUser();


is the counterpart to
userid = Application.BasicFunctions.CurrentUserID

Way to go Sage!
[Reply][Quote]
Mark Dykun
Posts: 297
 
Re: New to Web DevelopmentYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 28 Aug 09 9:54 PM
Yes, but to be fair the call in web returns more then just the Id. Also it iis quite easy to wrap this stuff up in a easier manner and Sage is aware and I expect they will be doing something to make accessing this kind of functionality easier in the future.

Mark
[Reply][Quote]
Matt Dockins
Posts: 159
 
Re: New to Web DevelopmentYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 29 Aug 09 6:11 PM
Yes, wrapping this stuff up into convenient and concise code is an ongoing project.
[Reply][Quote]
Matt Dockins
Posts: 159
 
Re: New to Web DevelopmentYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 30 Aug 09 12:26 PM

Sage.Platform.Security.IUserService userService = Sage.Platform.Application.ApplicationContext.Current.Services.Get();
string currentUserId = userService.UserId;
[Reply][Quote]
Ben240374
Posts: 10
 
Re: New to Web DevelopmentYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 06 Oct 10 8:58 AM
Hello,

I trying also to change the default account manager to current user on insert opportunity.
This code can change the lookup:

Sage.SalesLogix.Security.SLXUserService us = (Sage.SalesLogix.Security.SLXUserService) Sage.Platform.Application.ApplicationContext.Current.Services.Get();
string uid = us.UserId + "";

this.usrUser.LookupResultValue = uid;
this.usrUser.Text = us.UserName;

But when I save the opportunity, the account manager is the account manager from Account, not the current user.

what's wrong ?

Thanks

BEN
[Reply][Quote]
Ben240374
Posts: 10
 
Re: New to Web DevelopmentYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 06 Oct 10 9:00 AM
Sorry, just to say, I use SalesLogix 7.5.3
[Reply][Quote]
Lee Harris
Posts: 23
 
Re: New to Web DevelopmentYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 26 Mar 15 11:01 AM

Just to help out anyone else that stumbles across this post, like I did, trying to achieve the same thing, the following worked for me (Infor CRM Web 8.1) after reading the posts above.


In a new Form Load Action (C# Snippet Action) on the Insert Opportunity form you can use the following code to default the account manager to the current user (this is editable before saving).


 


//Default the opportunity account manager to the current logged in user


Sage.Entity.Interfaces.IOpportunity opportunity = BindingSource.Current as Sage.Entity.Interfaces.IOpportunity;


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


Sage.Entity.Interfaces.IUser user = Sage.Platform.EntityFactory.GetById<Sage.Entity.Interfaces.IUser>(userService.UserId);


opportunity.AccountManager = user;

[Reply][Quote]
Lee Harris
Posts: 23
 
Re: New to Web DevelopmentYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 26 Mar 15 11:01 AM

[deleted duplicate post]

[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/3/2025 7:18:39 AM