Showing results for 
Search instead for 
Do you mean 
Community Home Request Access Read Blogs Share Your Ideas Search Community View My Settings
Reply
Nickel Elite Contributor
Posts: 107
Registered: ‎03-09-2011
Accepted Solution

Slx Mobile 1.2 and queryWhere Keyword

I'm working on a customization that will limit records displayed to user.

 

I find that when I use the queryWhere the & character in the where clause gets converted to %26 and causes the url to fail.

 

Here is my SQL Sataement that proves my Query

 

SELECT     DESCRIPTION, TYPE, STATUS, ADDTOFORECAST
FROM         sysdba.OPPORTUNITY
WHERE     (TYPE <> 'Pipeline') AND (ADDTOFORECAST <> 'T') AND ((STATUS = 'Open') OR (STATUS = 'Pending'))

 I only want users to see Open and Pending Opportunities that are not Pipeline and Not in the forcast.

 

I have tried the following in the querywhere statement of the opportnity list just to get things atarted.

'Status eq \'Open\'&Type ne \'Pipeline\'&AddToForecast ne \'T\'', // & is converting to %26 and the query fails

 

queryWhere: 'Status eq \'Open\'\&Type ne \'Pipeline\'\&AddToForecast ne \'T\'', // escaping the & still converts to %26 and the query fails

 

queryWhere: encodeURI('Status eq \'Open\'&Type ne \'Pipeline\'&AddToForecast ne \'T\''), // encodeURI method & is still converting to %26 and the query fails

 encodeURIComponent fails as well

 

I'm stumped  How can I get the & to render in the where statement and not %26?

 

PS the query is not function as desired even if I manually convert the %26 characters to & I see piepline queries or closed queries. 

 

Any assistance is appreciated.

 

Gold Super Contributor
Posts: 3,087
Registered: ‎03-19-2009

Re: Slx Mobile 1.2 and queryWhere Keyword

Are you trying to do this using the "module override" approach as recommended in the argos-sample?

OR

Directly changing the OOTB code?

 

Override is the best practice way... and if it were written as a "hash Tag" query it would something look like:

'Type ne "Pipeline" and Status eq "Open" and ....'

--
RJ Ledger - rjledger@rjlSystems.net +1 603.369.3047 x101

".. Innovators in Mobility - Experts in Workflow Automation..."
http://www.rjlSystems.net - blog: www.rjlSystems.net/blog.html
Highlighted
Nickel Elite Contributor
Posts: 107
Registered: ‎03-09-2011

Re: Slx Mobile 1.2 and queryWhere Keyword

Here is a code snippett from my ApplicationModule.js that is overriding the Opportunity List

 

		Ext.override(Mobile.SalesLogix.Opportunity.List, {
			//override the template, don't ned the ugly UserID Codes on the list (Verifed Working)
            contentTemplate: new Simplate([                       
                '<h3>{%: $.Description %} <span class="p-account">{% if ($.Account) { %}({%: $.Account.AccountName %}){% } %}</span></h3>',
                '<h4>',
                '{%: $.Status %} {%: Mobile.SalesLogix.Format.currency($.SalesPotential) %}',
                '{% if ($.Stage) { %} | {%: $.Stage %}{% } %}',
                '{% if ($.Account) { %} | {%: $.Account.AccountManager.UserInfo.UserName %}{% } %}',
                //'{% if ($.Account.AccountManager.UserInfo.Region) { %} - {%: $.Account.AccountManager.UserInfo.Region %}{% } %}',
                '</h4>'
            ]),
			//queryWhere: 'Status eq \'Open\'&Type ne \'Pipeline\'&AddToForecast ne \'T\'', // & is converting to %26 and the query fails
			//trying &amp; did not work
			//trying encodeURI function did not work
			queryWhere: encodeURIComponent("Status eq 'Open' & Type ne 'Pipeline' & AddToForecast ne 'T'"), // encodeURIComponent method & is still converting to %26 and the query fails
		});

 

Nickel Elite Contributor
Posts: 107
Registered: ‎03-09-2011

Re: Slx Mobile 1.2 and queryWhere Keyword

[ Edited ]

Update

 

Tryiong the w3schools tryit yoursself

 

http://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_escape

 

with the following code demonstrates that I can get to the code I desire

 

<html>
<body>

<script type="text/javascript">

//document.write(escape("Status eq 'Open' & Type ne 'Pipeline' & AddToForecast ne 'T'"));
//& converts to %26
//document.write(encodeURIComponent("Status eq 'Open' & Type ne 'Pipeline' & AddToForecast ne 'T'"));
//& converts to %26
document.write(encodeURI("Status eq 'Open' & Type ne 'Pipeline' & AddToForecast ne 'T'"));
//works here but not in slxmobile still converts & to %26
</script>

</body>
</html>

 

 And YES I have been clearing my cache prior to each new attempt!

 

Gold Super Contributor
Posts: 3,087
Registered: ‎03-19-2009

Re: Slx Mobile 1.2 and queryWhere Keyword

Are you aware of the official SData Query Language spec?  I wrote about it in a blog and you can find it here: Click Here

--
RJ Ledger - rjledger@rjlSystems.net +1 603.369.3047 x101

".. Innovators in Mobility - Experts in Workflow Automation..."
http://www.rjlSystems.net - blog: www.rjlSystems.net/blog.html
Bronze Contributor
Posts: 95
Registered: ‎07-11-2011

Re: Slx Mobile 1.2 and queryWhere Keyword

All escaping is handled by the SDataJavascriptClient Library, if you like its on github and that part of the code is in SDataUri.js. As far as the & goes, it needs to be escaped as its used to separate parameters in a URL.

 

However, for doing a "logical and" the expression needs the keyword "and":

http://interop.sage.com/daisy/sdata/AnatomyOfAnSDataURL/QueryLanguage.html

 

You can see an example of this in Account Detail, under the related links at the bottom.

 

Which would let your customization look like:

Ext.override(Mobile.SalesLogix.Opportunity.List, {
    //override the template, don't ned the ugly UserID Codes on the list (Verifed Working)
    contentTemplate: new Simplate([                       
        '<h3>{%: $.Description %} <span class="p-account">{% if ($.Account) { %}({%: $.Account.AccountName %}){% } %}</span></h3>',
        '<h4>',
            '{%: $.Status %} {%: Mobile.SalesLogix.Format.currency($.SalesPotential) %}',
            '{% if ($.Stage) { %} | {%: $.Stage %}{% } %}',
            '{% if ($.Account) { %} | {%: $.Account.AccountManager.UserInfo.UserName %}{% } %}',
            //'{% if ($.Account.AccountManager.UserInfo.Region) { %} - {%: $.Account.AccountManager.UserInfo.Region %}{% } %}',
        '</h4>'
    ]),
    queryWhere: 'Status eq "Open" and Type ne "Pipeline" and AddToForecast ne "T"'
});

 

Hope that clears it up a bit!

 

Nickel Elite Contributor
Posts: 107
Registered: ‎03-09-2011

Re: Slx Mobile 1.2 and queryWhere Keyword

Thanks, I had reviewed the SData Query Language specification but the examples and documentation kind of confused me. I'm less than thrilled with the spec.

 

The change you provided works with the following exceptions

 

using aAddToForecast ne '"T" needs to read AddToForecast ne "true" as AddToForecast is cast to a boolean by SData.

 

Working now thanks.

 

I find this forum very helpful.