Home | Forums | Contact | Search | Syndication  
 
 [login] [create account]   Friday, April 19, 2024 
 
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: Generate a ticket's pretty key
Claudia
Posts: 23
 
Generate a ticket's pretty keyYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 24 Apr 08 4:42 PM
Hi guys,

I'm developing a stand-alone custom page that has to create a ticket.
That page must be opened without going first through the login page.
Sice a ticket can't be created without a logged in user,
I'm trying to create the ticket executing the necesary sql queries.
I haven't been able to figure out how to generate the ticket's pretty key.
That key is a combination of the ALTERNATEKEYPREFIX and ALTERNATEKEYSUFFIX fields, but I don't know how to generate these keys.
Anyone knows?
[Reply][Quote]
John-Paul Bow
Posts: 2
 
Re: Generate a ticket's pretty keyYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 25 Apr 08 2:17 AM
I can't say I know a whole lot about that process under the hood. Where I would start is the SQL transaction logs. Using log analyzing software we were able to reverse engineer some of our SLX and our SAGE processes. We used software called lumigent log analyzer, but there are others out there.
[Reply][Quote]
NixDev
Posts: 98
 
Re: Generate a ticket's pretty keyYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 19 Apr 09 8:20 PM
Apparently you can do it like this:

string altKeyPrefix = PrettyKeys.GetPrettyKeyPrefix(myEntityID);
string altKeySuffix = PrettyKeys.GetPrettyKeySuffix(myEntityID);

I have not tested this myself, but I came accross it on another thread.
[Reply][Quote]
Andy Norris
Posts: 39
 
Re: Generate a ticket's pretty keyYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 20 Apr 09 1:59 PM
If you're inserting manually, you still use the slx_dbids() function. See below for a Ticket example - should work for you but let me know if not.....

------------

string slxNewTicketId = "";
Sage.Platform.Data.IDataService service = Sage.Platform.Application.ApplicationContext.Current.Services.Get();
string constr = service.GetConnectionString();
OleDbConnection conn = new OleDbConnection(constr);
conn.Open();
string commandText = String.Format(CultureInfo.CurrentCulture, "slx_dbids('{0}', 1)", "TICKET");
OleDbCommand cmd = new OleDbCommand(commandText, conn);
object result = null;
try
{
result = cmd.ExecuteScalar();
}
catch
{
throw new Exception("cannot fetch ID");
}
finally
{
conn.Close();
}
slxNewTicketId = result.ToString();


string slxAltKeyPrefix = Sage.SalesLogix.PrettyKey.GetPrettyKeyPrefix(slxNewTicketId);
string slxAltKeySuffix = Sage.SalesLogix.PrettyKey.GetPrettyKeySuffix(slxNewTicketId);

string ticketSQL = "INSERT INTO TICKET (TICKETID, ALTERNATEKEYPREFIX, ALTERNATEKEYSUFFIX) VALUES (?,?,?)";

cmd = new OleDbCommand();
cmd.Parameters.Clear();
cmd.Connection = conn;
cmd.CommandText = ticketSQL;
cmd.Parameters.Clear();
cmd.Parameters.AddWithValue("@TICKETID", slxNewTicketId);
cmd.Parameters.AddWithValue("@ALTERNATEKEYPREFIX", slxAltKeyPrefix);
cmd.Parameters.AddWithValue("@ALTERNATEKEYSUFFIX", slxAltKeySuffix);
cmd.ExecuteNonQuery();

[Reply][Quote]
Ryan Farley
Posts: 2265
slxdeveloper.com Site Administrator
Top 10 forum poster: 2265 posts
 
Re: Generate a ticket's pretty keyYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 21 Apr 09 1:02 AM
Isn't it just easier to add via the entity model (and have any entity events and business rules fire) than to do a SQL insert? Doing it this way, you can just omit the keyprefix/keysuffix and then populate them on the OnAfterInsert event of the Ticket entity.

Sage.Entity.Interfaces.ITicket ticket = Sage.Platform.EntityFactory.Create<Sage.Entity.Interfaces.ITicket>();
// don't populate these now
//ticket.AlternateKeyPrefix
//ticket.AlternateKeySuffix
ticket.Account = account;
ticket.Notes = "Testing...";
ticket.Save();


Now in the OnAfterInsert you just check to see if the ticket is missing those and create as needed. I only mention this because doing a direct SQL insert, besides being a huge pain, will cause any code in the entity events to not fire. The OOTB system *does* have code that fires in these events - doing the direct SQL insert will cause those to not fire.

-Ryan
[Reply][Quote]
Andy Norris
Posts: 39
 
Re: Generate a ticket's pretty keyYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 27 Apr 09 1:01 PM
Ryan - Won't the method you're using there require a logged-in user to work? The OP was asking how to do this without having a logged in user....
[Reply][Quote]
Ryan Farley
Posts: 2265
slxdeveloper.com Site Administrator
Top 10 forum poster: 2265 posts
 
Re: Generate a ticket's pretty keyYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 27 Apr 09 2:09 PM
Quote:
Originally posted by Andy Norris

Ryan - Won't the method you're using there require a logged-in user to work? The OP was asking how to do this without having a logged in user....


Ah, right. I completely missed that. Yes, that way will require a logged in user. You could accomplish the same using SData/REST as well as another option. It will require a "logged in user", but that is something you do via the code, not actually requiring the user to log in.
[Reply][Quote]
Raul A. Chavez
Posts: 1300
Top 10 forum poster: 1300 posts
 
Re: Generate a ticket's pretty keyYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 28 Apr 09 1:02 AM
Well, here is how you do it if you don't have access to the Web Client Entities and Objects (you will need to have generated a Ticket ID, since the AlternateKeySuffix is based on the TicketID):

The Alternate Key Prefix can be had from the Database:
SELECT KEYPREFIX + '-00' FROM SITEOPTIONS WHERE SITECODE IN (SELECT SITECODE FROM SYSTEMINFO)
* Note: The Middle component is typically 00, but I believe it could change based on the Database Type. When I have done this in the past, I have typically kept it as 00.

Now, the Alternate Key Suffix requires as Input the TicketID. It is a Base 36 calculation for the last 6 Characters of the TicketID.
For Instance, a Ticket ID of "t6UJ9A0029RS" will result on a Key Suffix of "105976"
Which can be calculated as Follows (working backwards on the last 6 chars):
ASCII(S) - ASCII(A) [28]
+
(ASCII(R) - ASCII(A)) * 36 [27 * 36 = 972]
+
9 * 36^2 [9 * 1,296 = 11,664]
+
2 * 36^3 [2 * 46,656 = 93,312]
+
0 * 36^4 [0 * 1,679,616 = 0]
+
0 * 36^5 [0 * 60,466,176 = 0]

Resolving each part that gives us:
28+972+11,664+93,312
And that adds up to 105,976

So, if our Key Prefix = '005', the resulting ID would've been:
005-00-105976
[Reply][Quote]
NagaratnaPandi
Posts: 111
 
Re: Generate a ticket's pretty keyYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 19 Oct 09 9:31 AM
Hi,
I want to gererate the pretty key for sales order.
I want to create this using SQL.
I will be able to pass the Sales Order ID.
Will the above method will work for this.

In the above method ASCII(S) - ASCII(A) will be 18 only right.(You said 28)
If my sales order id is "Q6UJ9A01OL79" Then how can i generate the sales order pretty key??
In the above method the characters in the postions from last 2,3,4 are 9,0,0.
If i get the characters in the respective position then what should i do?
[Reply][Quote]
Jonathan Dixon
Posts: 2
 
Re: Generate a ticket's pretty keyYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 16 Feb 17 4:21 PM

I had an issue today where I tried to import some old quotes from a different database into our InforCRM Saleslogix system.


I found this post and I had to fiddle with it to get it to work. Excuse the awful SQL, but this get's the values:


What I needed to unpack was the BASE36 value of each digit.  0-9 is easy, but A = 10, B = 11, etc.


After that it's a matter of multiplying the base 36 value by the power of it's place starting at 0.  So the first digit is it's (base36 value) * 36^0.  The second digit is its (base 36 value) * 36^1, etc.


Add them all together to get the Pretty Key.  ALTERNATEKEYSUFFIX


 


 


SELECT A.DIGIT1*POWER(36,0)  

+ A.DIGIT2*POWER(36,1)

+ A.DIGIT3*POWER(36,2)

+ A.DIGIT4*POWER(36,3)

+ A.DIGIT5*POWER(36,4)

+ A.DIGIT6*POWER(36,5)

AS PRETTYKEY

FROM

(

SELECT QUOTEID

, ALTERNATEKEYSUFFIX

, CASE

WHEN SUBSTRING(QUOTEID, LEN(QUOTEID)-0,1) LIKE '[0-9]' THEN SUBSTRING(QUOTEID, LEN(QUOTEID)-0,1)

ELSE  ASCII(SUBSTRING(QUOTEID, LEN(QUOTEID)-0,1)) - ASCII('A')+10

END AS DIGIT1

 

, CASE

WHEN SUBSTRING(QUOTEID, LEN(QUOTEID)-1,1) LIKE '[0-9]' THEN SUBSTRING(QUOTEID, LEN(QUOTEID)-1,1)

ELSE  ASCII(SUBSTRING(QUOTEID, LEN(QUOTEID)-1,1)) - ASCII('A')+10

END AS DIGIT2


, CASE

WHEN SUBSTRING(QUOTEID, LEN(QUOTEID)-2,1) LIKE '[0-9]' THEN SUBSTRING(QUOTEID, LEN(QUOTEID)-2,1)

ELSE  ASCII(SUBSTRING(QUOTEID, LEN(QUOTEID)-2,1)) - ASCII('A')+10

END AS DIGIT3


, CASE

WHEN SUBSTRING(QUOTEID, LEN(QUOTEID)-3,1) LIKE '[0-9]' THEN SUBSTRING(QUOTEID, LEN(QUOTEID)-3,1)

ELSE  ASCII(SUBSTRING(QUOTEID, LEN(QUOTEID)-3,1)) - ASCII('A')+10

END AS DIGIT4


, CASE

WHEN SUBSTRING(QUOTEID, LEN(QUOTEID)-4,1) LIKE '[0-9]' THEN SUBSTRING(QUOTEID, LEN(QUOTEID)-4,1)

ELSE  ASCII(SUBSTRING(QUOTEID, LEN(QUOTEID)-4,1)) - ASCII('A')+10

END AS DIGIT5


, CASE

WHEN SUBSTRING(QUOTEID, LEN(QUOTEID)-5,1) LIKE '[0-9]' THEN SUBSTRING(QUOTEID, LEN(QUOTEID)-5,1)

ELSE  ASCII(SUBSTRING(QUOTEID, LEN(QUOTEID)-5,1)) - ASCII('A')+10

END AS DIGIT6

 

FROM SalesLogix.sysdba.QUOTE 


) A


 


Here is some C# code. It got a little fiddly with data-types but this got what I needed for the ALTERNATESUFFIX


 


 


            string inforId = "Q06VXA0087HW";

            double prettyKey = 0;

            for (int i = 1; i <= 6; i = i + 1)

            {

                char c = Convert.ToChar(inforId.Substring(inforId.Length - i, 1));

                int base36 = 0;

                if (Char.IsNumber(c))

                {

                    Int32.TryParse(c.ToString(), out base36);

                }

                else

                {

                    base36 = ((int)c-55);

                }

                prettyKey += base36 * Math.Pow(36, i - 1);

            }

            Console.WriteLine(prettyKey);


 

[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 © 2024 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): 4/19/2024 8:58:23 AM