Tuesday 3 January 2012

HQL Datasource

Blank Form
Create new HQL datasource
From Clause: Choose entity (table) name
Columns: Enter datafields as from teh Entity. (Case sensitive)
Where Clause: as needed.


Enter Datagrid:
Set the datasource to hql datasource.
Enter columns in grid as per what was created manually in hql columns

Form load can manipulate the where clause:
Sage.Entity.Interfaces.IFxTrans trans =
this.BindingSource.Current as Sage.Entity.Interfaces.IFxTrans;

string tranid = trans.TranId.ToString();

this.QFHqlDataSource.Where = "TranId = " + tranid;





 Here are some quick pointers on HQL data sources...

1) You can think of the HQL Data source as a Query builder. The Query is broken up into sections as defined in the HQL data source properties. Columns is the "select" part, From and Where are, well... from and where.

2) The parameters section is used to pass a value into the HQL Query's where clause. Currently, only the Current Entities Id can be passed in "EntityId". Looks like you have that down.

3) The From clause must define the relationship with each entity you want to use. For Example: "Contact c" would reference a single entity, but if you want to activities for that contact, you would put this in the From... "Contact c join c.Activity a". This tells the query to join to activity from contact using the relationship that is defined on the Contact entity that joins to Activity. Tip: you can also use "left join" if it's appropriate.

3) Now you can add all of the Columns you want to use as the "select" part of the Query. Add a column from the Columns property and put the Value you want to use (e.g "c.LastName" or "c.Account"). Add a column for each property you want to use. Tip: Since we are still talking about Entity properties, you can also reference other related entities direcly (e.g. "c.Account.Owner" or "c.AccountManager,UserInfo.Direct"). One warning with using this method, is that is implies an Inner Join, so the entire record will be omitted if any of the properties are Null. Define the relationship in the From property of you need to "allow nulls" with a Left Join.

4) If you want to use an edit form for the main entity in the HQL query, don't forget to include that Id property in your columns. Then , be sure to reference that property on the Key field for your Data Grid (e.g. "c.Id").

Sample Code Snippet Property

public static void GetBuy_SellStep( IFxTranExs fxtranexs, out System.String result)

{
    Sage.Entity.Interfaces.IFxTranExs transaction = fxtranexs;
    string test = "";
    if (transaction.BuySell == "B") { test = "Buy"; }
    if (transaction.BuySell == "S") { test = "Sell"; }

    result = test;
}

Friday 9 December 2011

SalesLogix Format Strings

In QuickForm Grid View:
{0:2C} Currency
{0:#,##0}



Quick Form Controls



Enter the Format string in the Databinding property.
Use following table to determine format string:
CharacterDescriptionExamplesOutput
C or cCurrencyConsole.Write("{0:C}", 2.5);
Console.Write("{0:C}", -2.5);
$2.50
($2.50)
D or dDecimalConsole.Write("{0:D5}", 25);00025
E or eScientificConsole.Write("{0:E}", 250000);2.500000E+005
F or fFixed-pointConsole.Write("{0:F2}", 25);
Console.Write("{0:F0}", 25);
25.00
25
G or gGeneralConsole.Write("{0:G}", 2.5);2.5
N or nNumberConsole.Write("{0:N}", 2500000);2,500,000.00
X or xHexadecimalConsole.Write("{0:X}", 250);
Console.Write("{0:X}", 0xffff);
FA
FFFF


In Mainview Group Builder view:
Use format strings as listed in LAN Architect help

[%] [type]

If necessary, you can also include an argument index specifier, a left justification indicator, a width specifier, and a precision specifier:

[%] [index:] [-] [width] [.precision] [type]

Example Format String for Numeric (float) value:
$%0.2f