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!
|
|
Creating a ticket using code
Posted: 17 Apr 08 5:40 PM
|
I created a custom page that has to create a ticket. I'm usign this line of code to get an instance of an object Ticket.
ITicket ticket = Sage.Platform.EntityFactory.Create();
I have used this function to create other objects like Account, Contact, Address and some custom entities and worked perfectly. Now that I'm using it with a Ticket it throws and asp.net error
Object reference not set to an instance of an object.
Does anyone know why it could be failing? or does anyone know another way to create a ticket? |
|
|
|
Re: Creating a ticket using code
Posted: 25 Apr 08 3:49 PM
|
Claudia, Did you ever figure this out? I have the following code that creates a contact and also needs to create a ticket. I am getting the same Object reference not set to an instance of an object error. The failing code is the ticket piece at the bottom. It fails in Ticket.CS ITicket Create() on this line: lib.Execute("Ticket.OnCreate", methodArgs);
--failing code,Contact insert ok - ticket is failing. private void SaveValues(IAccount objAccount) { IAddress conaddress = Sage.Platform.EntityFactory.Create(); conaddress.Address1 = txtStreet.Text; conaddress.City = txtCity.Text; conaddress.State = State.PickListValue; conaddress.PostalCode = txtPostalCode.Text; conaddress.Country = Country.PickListValue; conaddress.Description = "Mailing";
IContact con = Sage.Platform.EntityFactory.Create(); con.FirstName = txtFirstName.Text; con.LastName = txtLastName.Text; con.WorkPhone = phnWorkPhone.Text; con.HomePhone = phnHomePhone.Text; con.Mobile = phnCellPhone.Text; con.Email = txtEmailAddress.Text; con.AlternateEmail1 = txtEmail1.Text; con.AlternateEmail2 = txtEmail2.Text;
con.Address = conaddress; con.DoNotEmail = false; con.DoNotFax = false; con.DoNotMail = false; con.DoNotPhone = false; con.DoNotSolicit = false; con.Account = objAccount; con.AccountName = objAccount.AccountName; con.Owner = objAccount.Owner; con.WebUserName = txtEmailAddress.Text.Replace("@","_"); con.WebPassword = txtLoginPassword.Text; con.SaveWebAccess(true, txtLoginPassword.Text, txtVerifyPassword.Text); con.Save(); conaddress.EntityId = con.Id.ToString(); conaddress.Save();
con.WebUserName = con.Email; con.Save(); // ITicket tic = Sage.Platform.EntityFactory.Create(); tic.ContactId=con.Id.ToString(); tic.AccountId=objAccount.Id.ToString(); tic.Save(); } |
|
|
|
Re: Creating a ticket using code
Posted: 29 Apr 08 9:48 AM
|
What I figured out about this error is that in order to create a ticket object there must be a logged in portal user. The page where I put that code is a page that has to be opened out of a user session (without logging in a user), so in my case, that error is happening because there is no user session initialized.
Are you using that code in a page like mine or in a LeadCapture Portal's page? |
|
|
|
Re: Creating a ticket using code
Posted: 30 Apr 08 9:56 AM
|
I am having trouble in both cases. Even the oob insert portal ticket screen is failing in the 'anonomous' portal scenario. |
|
|
|
Re: Creating a ticket using code
Posted: 02 May 08 2:29 PM
|
Is it possible to insert a record not using fuctions from the customer portal, like I was coding a stand alone asp.net application using the SLX Provider? The fact that I am logging into the portal anonomously is making ticket creation with the entity model seemingly out of the question. Can I generate a TicketID and perform an insert with ADO? Any other thoughts? This has turned into a a major show stopper. Thanks |
|
|
|
Re: Creating a ticket using code
Posted: 02 May 08 2:56 PM
|
Absolutely. I do it all the time. No need to use the entity model to do it, just insert the data as needed. Did you have specific questions about doing this? |
|
|
| |
|
Re: Creating a ticket using code
Posted: 03 May 08 9:33 AM
|
Ok, I see the ID creation is well documented in an article on this very site. Nice article, thanks Ryan. My next obstacle? Creating the atlernatekeyprefix and alternatekeysuffix from the 7.2 web client. Any tips on this? Thanks |
|
|
|
Re: Creating a ticket using code
Posted: 03 May 08 9:44 AM
|
Got the goods for pretty key generation through 7.2 web:
string AltKeyPrefix = PrettyKeys.GetPrettyKeyPrefix(tickID); string AltKeySuffix = PrettyKeys.GetPrettyKeySuffix(tickID); |
|
|
|