Showing results for 
Search instead for 
Do you mean 
Community Home Request Access Read Blogs Share Your Ideas Search Community View My Settings
Reply
Copper Super Contributor
Posts: 172
Registered: ‎07-06-2010
Accepted Solution

Entity Events in SlxMobile/SDATA

Is it possible to use the entity events that are exposed in App Architect for the same events that occur in SlxMobile/SDATA?

 

I have created, in Account.OnAfterInsert, an additional Post Flush step that runs correctly in the web app.

 

When I deployed to my SDATA portal, it does not appear that the Post Flush step was executed. The account saved, but Post Flush never ran. I deployed the BIN folder contents and 2 modified XML files. 

 

I am trying to find a manageable workaround for tapping into the Save event in SlxMobile. I have had a lot of trouble with this, and rather than having to rewrite the same code that is in the Post Flush step I was hoping the method would still execute.

 

Can anyone offer advice? Aside from not wanting to rewrite the code already in my external assembly, I really don't want to waste time banging my head trying to figure out how to get my app code to run in SlxMobile AFTER the Account and Contact are created.

Bronze Super Contributor
Posts: 129
Registered: ‎06-09-2009

Re: Entity Events in SlxMobile/SDATA

Did you re-deploy the SDATA portal and verify that the updated files made their way into the bin folder?

 

My experience is that the events do fire and execute. I have built validation rules into some of these events, and they fire as well from the Mobile client (through the SDATA portal).

Raul A. Chavez
http://raul.chavez.com
http://www.crmbi.com
Copper Super Contributor
Posts: 172
Registered: ‎07-06-2010

Re: Entity Events in SlxMobile/SDATA

[ Edited ]

Yep, hand copied them myself from the SDATA deployment folder (the entire BIN folder). 10 total files, and 3 non-SLX generated assemblies that are dependencies for the external assembly.

 

The event OnAfterInsert calls a method I wrote in this external assembly. Nothing is written to the Event Viewer as far as exceptions go, but I can tell the code didnt run because I've tested it in the web deployment and it works correctly. The records for both Account and Contact are written but my method that adds additional data to Account after its saved doesnt appear to have executed.

 

 

 

 

Bronze Super Contributor
Posts: 236
Registered: ‎03-30-2009

Re: Entity Events in SlxMobile/SDATA

You need to make sure that your external assembly is also included inthe SData/SupportFiles/bin folder so it gets deployed to the SData site.  Every time you change the code, you will need to copy it to both SData and SLXClient web portals.

 

Also note that Sage.SalesLogix.API.dll (the one with the MySLX stuff in it) was not put in the SData protal either, so you'll likely want to copy that one their as well.

Mike LaSpina
Professional Services Consultant

Sage
8800 N Gainey Center Dr Ste 200
Scottsdale AZ 85258
Tel: 480-383-5344
Cell: 480-321-6637
Fax: 480-556-4090
mike.laspina@sage.com

Your Business in Mind.
Copper Super Contributor
Posts: 172
Registered: ‎07-06-2010

Re: Entity Events in SlxMobile/SDATA

I think I know why its breaking.

In OnAfterInsert I am querying SlxUserService to get some information on the user making the request. Is this service still accessible from Mobile in this context?

var userService =
Sage.Platform.Application.ApplicationContext.Current.Services.Get<Sage.Platform.Security.IUserService>()
as Sage.SalesLogix.Security.SLXUserService;
if (userService == null) throw new InvalidOperationException("SLX Exception - Unable to retrieve UserService object");
var user = userService.GetUser();
if (user == null) throw new NullReferenceException("SLX Exception - Unable to retrieve user object from SLX.");
if (string.IsNullOrEmpty(user.UserProfile.EmployeeNumber)) throw new Exception(@"SLX Exception - Employee Number value from SLX user profile is not saved in SLX.");
Bronze Super Contributor
Posts: 236
Registered: ‎03-30-2009

Re: Entity Events in SlxMobile/SDATA

I would copy the Sage.SalesLogix.API.dll to the sdata/bin folder and use MySlx to get the current user instead.  That does work via SData.

Mike LaSpina
Professional Services Consultant

Sage
8800 N Gainey Center Dr Ste 200
Scottsdale AZ 85258
Tel: 480-383-5344
Cell: 480-321-6637
Fax: 480-556-4090
mike.laspina@sage.com

Your Business in Mind.
Copper Super Contributor
Posts: 172
Registered: ‎07-06-2010

Re: Entity Events in SlxMobile/SDATA

[ Edited ]

This didn't work.

 

It appears that the OnAfterInsert event isn't firing at all. I edited the module to use MySlx but it doesn't appear to even get into the OnAfterInsert method. All the mobile app does after saving is redirect to the Account Details view.

 

In my external assembly I stripped out everything and added this:

 

public static void OnAfterInsert(IAccount account)
{

     account.AccountName = "From the Module";
     account.Save();

     return;

}

 

What I expected was this new account name would overwrite what I input into mobile. That never happened. 

 

I have other events in the assembly that also are not firing - OnBeforeInsert and OnBeforeUpdate. Each contains some simple code that validates zip code syntax for a given country selection. I intentionally put bad zips in there and the app acted like nothing happened. 

 

My SDATA feed URL appears to be correct as it is writing to the database I want to work with. But nothing appears to be happening outside of the save.

Bronze Super Contributor
Posts: 236
Registered: ‎03-30-2009

Re: Entity Events in SlxMobile/SDATA

[ Edited ]

That code should fire.  A couple of things:

  1. Make sure you have a primary step.  If you code a pre or post exec step and there is no active primary step, the pre and post steps will not fire.
  2. The account.Save() call you mentioned will cause an error.  You can not save an entity from within its own events.  Check your windows event log and you should see an error complaining about the save and flush operations.
  3. If you want to change a value for the account being saved, you need to do that in the OnBeforeInsert / OnBeforeUpdate events.  Once the OnAfter fires, the record has been saved to the DB and you can not save any more changes to it (although you can change OTHER records in the OnAfter events).
Mike LaSpina
Professional Services Consultant

Sage
8800 N Gainey Center Dr Ste 200
Scottsdale AZ 85258
Tel: 480-383-5344
Cell: 480-321-6637
Fax: 480-556-4090
mike.laspina@sage.com

Your Business in Mind.
Copper Super Contributor
Posts: 172
Registered: ‎07-06-2010

Re: Entity Events in SlxMobile/SDATA

I'll try this. There is a Primary step, and it's OnAfterInsert but it's pointing to Sage.SalesLogix.BusinessRules. Shouldn't this be my external assembly? 

 

Actually I dont want to save back to the Account; I just threw something, anything in there to see if it would go. 

 

 

Bronze Super Contributor
Posts: 236
Registered: ‎03-30-2009

Re: Entity Events in SlxMobile/SDATA

A few versions ago, dev put in some default CRUD handlers to overcome the problem with pre and post events not firing.  Just make sure the primary step is there and active and you should be good.

Mike LaSpina
Professional Services Consultant

Sage
8800 N Gainey Center Dr Ste 200
Scottsdale AZ 85258
Tel: 480-383-5344
Cell: 480-321-6637
Fax: 480-556-4090
mike.laspina@sage.com

Your Business in Mind.