Showing results for 
Search instead for 
Do you mean 
Community Home Request Access Read Blogs Share Your Ideas Search Community View My Settings
Reply
Highlighted
New Member
Posts: 8
Registered: ‎02-09-2011
Accepted Solution

HQL data source question

Hello,

 

I need help with a HQL data source.  I've set up an HQL data source and a grid in a form under the Contact entity.  I wanted to show rows of a table/entity that have the same contactid. 

 

i've set up all the parameters according to the help in Architect, including setting up a parameter called cid with EntityId as its value. 

 

I know that EntityID resolves into the Id of the entity, in this case ContactID; and I use :cid in my where clause of HQL data soure.  This works perfectly. 

 

Now, If I want to use another property of Contact, let say lastname in my where clause, how would I refer to it in my parameters property ?  I tried something like fn=Contact.FirstName but when I use :fn in my where clause I get a null point exception.

 

Any help would be appreciated.

Highlighted
Loyal Listener
Posts: 20
Registered: ‎03-11-2009

Re: HQL data source question

Hello Joe,

 

you don't have to make those fields a parameter I think. Just try to use c.Firstname in your where... (imagine that you had contact c in your FROM).

 

There is good documentation in the Help with an example of magic carpets. Maybe have a look at that. The help in the application architect is getting better and better.

 

Thanks,

Sascha

Highlighted
Nickel Contributor
Posts: 51
Registered: ‎07-31-2008

Re: HQL data source question

Joe - 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").

Hope this helps!

-Jeremy
Highlighted
New Member
Posts: 8
Registered: ‎02-09-2011

Re: HQL data source question

Perfect explanation, Thanks!

Highlighted
New Member
Posts: 16
Registered: ‎02-18-2011

Re: HQL data source question

Is hql datasource available in 7.5.2?

I don't see it as an option when building a quickform, but it is shown in one of the developer videos labeled 7.5.2.

Add a Where Condition to a Data Grid
Publication Date: 2010/07/29