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!
|
|
Assign Ticket to a team
Posted: 14 Mar 08 12:03 PM
|
I have an insert form that adds data to an extension table off Ticket. When the form is submitted a ticket and extension record are added by the form automagically. I need to assign the ticket to a certain team. I tried using a hardcoded field with the properID bound to the Ticket.AssignedToId in hope of more auto-magic. Of course I am not so lucky. I am thinking I am going to have to run an update statement after the insert to make this happen..
So I was wondering if I could get a little feedback from those who have done this type of thing.. 1. Do I need to run an update statement somewhere or is there a way to assign the ticket on the initial automagic insert? 2. When my insert form is submitted, it seems like the extension table gets inserted first. If I need to run an update, when would I do this and how do I get the new TicketID to do so?
Thanks |
|
|
|
Re: Assign Ticket to a team
Posted: 15 Mar 08 12:04 AM
|
On the ticket entity, look at the events. That is where you'll want to put this logic. You can add a step to an event (or more likely a post step since the OOTB code already executes a primary step). You won't need to run an update statement, just set the Owner property to the proper SecCodeID and it will save with the rest of the data.
Always shoot for adding that sort of logic (meaning business rules of any kind) to the entity model, never to the form. This will make future upgrades much easier since you keep all logic in the model and not on the forms.
Does that make sense? |
|
|
|
Re: Assign Ticket to a team
Posted: 15 Mar 08 11:07 AM
|
Thanks Ryan, that makes sense. I know exactly where you mean to put the code. What would the code look like to access this property without SQL? I am still wrapping my head around not working with SQL so much for these types of tasks.. |
|
|
|
Re: Assign Ticket to a team
Posted: 15 Mar 08 11:59 AM
|
I tried adding this code snip to the OnBeforeInsert event of my extension entity for ticket: Public Shared Sub OnBeforeInsertStep1( ByVal odmcertpc As IODMCERTPC, ByVal session As ISession) odmcertpc.Ticket.AssignedTo="FDEMOA00000Q".toString End Sub
I am gettting an error that says "Could not save object: Unable to locate type information". Am I on the right track and what am I missing? Thanks |
|
|
|
Re: Assign Ticket to a team
Posted: 15 Mar 08 12:35 PM
|
The AssignedTo property is an object, of type Owner, not a string. You can't assign a string to it. You have to instead load the Owner object for the SECCODEID and then set that. I think you can do something like this (off top of head so might not be right)
ticket.AssignedTo = Owner.GetByOwnerId("FDEMOA00000Q")
Does that make sense?
|
|
|
|
Re: Assign Ticket to a team
Posted: 15 Mar 08 2:36 PM
|
Hmm.. can't quite seem to get it. Owner.GetByOwnerId throws an error during the web platform build - "Owner' is not declared. I don't get any intellisense after Owner.[] in the slx code editor.. I tried Ticket.Owner... but had no method like GetByOwnerId... Nothing like groping in the dark.. hehehe. A developers reference with code samples sure would be helpful. |
|
|
|
Re: Assign Ticket to a team
Posted: 15 Mar 08 7:53 PM
|
Try either adding the following to your usings (or Imports if VB.NET)
using Sage.SalesLogix.Security;
or use the fully qualified name in teh code:
ticket.AssignedTo = Sage.SalesLogix.Security.Owner.GetByOwnerId("XXXXX.....");
I can't remember if the top of my head if Sage.SalesLogix.Security is referenced for code snippets (if not, do a search in this forum for codesnippets.xml to find out how to add the reference) |
|
|
|
Re: Assign Ticket to a team
Posted: 16 Mar 08 8:31 AM
|
Hmmm.. I tried adding 'Imports Sage.SalesLogixSecurity' in the #Region "Usings" section of the vb code snip - The build output told me that 'Sage.SalesLogix.Security' doesn't contain any public member or cannot be found'.
I also tried the fully qualified name: odmcertpc.Ticket.AssignedTo=Sage.SalesLogix.Owner.GetByOwnerId("FDEMOA00000Q")
The build output threw an error: 'SalesLogix' is not member of 'Sage'.
Thanks for your efforts Ryan, I appreciate the feedback. |
|
|
|
Re: Assign Ticket to a team
Posted: 16 Mar 08 9:35 AM
|
Ok, Past my build errors, but getting the 'could not save object: Unable to locate type information' again.
I am on 7.2, so I added Sage.SalesLogix.Security.dll and Sage.SalesLogix.dll to the Sage.Platform.Orm.Entities.CodeSnippetHeader assembly references collection. I also added Imports Sage.SalesLogix and Imports Sage.SalesLogix.Security to the code snip. The path I added is C:\Documents and Settings\Administrator\Application Data\Sage\Platform\Output\assemblies\xxxx.dll for both .dll's.
Here is my currently failing code snip: Public Shared Sub OnBeforeInsertStep1( ByVal odmcertpc As IODMCERTPC, ByVal session As ISession) ' TODO: Complete business rule implementation odmcertpc.Ticket.AssignedTo=Sage.SalesLogix.Security.Owner.GetByOwnerId("FDEMOA00000Q") End Sub |
|
|
|
Re: Assign Ticket to a team
Posted: 16 Mar 08 12:36 PM
|
I wonder if that is because you're doing this from the child/extension entity? I always do this sort of thing from the parent (myself, I would add this code to a Ticket level event instead). Is there a reason why you're doing this from the child/extension entity? Maybe try this code from the Ticket OnBeforeInsert event (You'll still be able to get to the extension's properties as well if that is what you're needing).
??? Strange error.
-Ryan |
|
|
|
Re: Assign Ticket to a team
Posted: 16 Mar 08 1:57 PM
|
I was trying it from the extension table as I am not sure if this event will be fired every time a ticket is added. In the name of science I tried from the ticket event with the same error. |
|
|
|