I am working with the Rally/Excel plug-in and setting up queries/filters for our various delivery teams. One of the teams is named "Agency / L&C". The & is causing me all sorts of problems that I cannot seem to get past. The current filter is:
((Release.Name = "2013 November") AND (Project.Name = "Agency / L&C"))
When I execute the query I get this error:
Query failed due to errors:
Could not parse: Cannot parse expression "((Release.Name = "2013 November") AND (Project.Name = "Agency / L" as a query
I have tried several things, ' before and after, '' before and after, %, " and \ and nothing seems to be making it register the & as text.
Thanks for the help
This is an educated guess but I would think the problem arises from the ampersand not being escaped before the request is made to the to the API. You might try changing it to "%26" (the HTML code for "&") and see what you get.
Related
Long story short, I have a sql query pulling data from a database into a spreadsheet. I want to be able to change the Plant filter inside the query via Power Query, I have tried using a custom function and adding that into the query where the variable is set (see below)
Sql.Database("server", "database", [Query="DECLARE #FilterOnPlant AS varchar(3)#(lf)SET #FilterOnPlant = '" + filterOnPlant + "'#(lf)#(lf)SELECT
In doing this I keep getting the following error:
Expression.Error: We cannot apply operator + to types Text and Table.
Details:
Operator=+
Left=DECLARE #FilterOnPlant AS varchar(3)
SET #FilterOnPlant = '
Right=[Table]
I figure it has something to do with the '+' operator used but can't find an alternative.
I have tried using:
'&'
'+'
'and'
but they all yield the same error (with the exception of 'and' that error states that it's not being used in a logical statement which makes sense)
For further info:
The custom function to get the value I want is:
filterOnPlant = Excel.CurrentWorkbook(){[Name="Active_Plant"]}[Content]
The intention is to get the Value from a cell Named "Active_Plant"
EDIT:
after further testing I have found the issue lies with variable filterOnPlant, when I exchange that for a string value then the query works as expected. If anyone knows how I can get CELL().Value of a named range in power query would be super helpful
Solved!
In my filterOnPlant function I was missing {0}[Column1]
Original: filterOnPlant = Excel.CurrentWorkbook(){[Name="Active_Plant"]}[Content]
New (Working): filterOnPlant = Excel.CurrentWorkbook(){[Name="Active_Plant"]}[Content]{0}[Column1]
I've a script with an object launchpoint on INVOICELINE.
For the mbo I want to get all INVOICELINES with the same PONUM as the current MBO (since they could be in other then the current mbo's invoice)
In the script I find the PO like so: (to test for status)
from psdi.server import MXServer
from psdi.mbo import Mbo
from psdi.mbo import MboConstants
from psdi.security import UserInfo
from psdi.server import MXServer
myMXServer = MXServer.getMXServer()
userInfo = mbo.getThisMboSet().getUserInfo()
# find the PO
poSet = myMXServer.getMboSet("PO", userInfo)
poSetWhere = "ponum='" + mbo.getString("PONUM") + "' and siteid='" + mbo.getString("POSITEID") + "' and status not in " + poNoUpdate
poSet.setWhere(poSetWhere)
poMbo = poSet.getMbo(0)
which works great.
then later I do the very same for the set of invoicelines:
ilSet = myMXServer.getMboSet("INVOICELINE", userInfo)
ilSetWhere = "ponum='" + mbo.getString("PONUM") + "' and positeid='" + mbo.getString("POSITEID") + "'"
ilSet.setWhere(ilSetWhere)
ilMbo = ilSet.moveFirst()
while ilMbo is not None:
...
which results in a error on the setWhere line. Curiously, logging (which I removed for readability) indicates that ilSet contains all invoicelines records after the getMboSet (as expected), the ilSetWhere has a valid query that you can copy-paste in SQL Developer.
Does Maximo need some index or so before it can execute this setWhere?
Here is the logging result for the two setWhere strings:
ponum='4140006682' and siteid='mysite' and status not in ('CLOSED','CAN','GESLTN','ANN')
and
ponum='4140006682' and positeid='mysite'
The error I get is a generic BMXAA7837E java.lang.NullPointerException in script at line... (the line refers to the line with the ilSet.setWhere(ilSetWhere) expression. I'm out of ideas how to fix this and have no clue how to work around it.
Now we have an error to work with!
Maximo effectively insists that an INVOICELINE set has an "owner", which you have not set up in your code example. Think of an owner as a parent set. Specifically, it is the MBOSet used to fetch the current set off of. It doesn't actually have to be related to the current set, but most of the time it will be (and it makes the most sense to fetch sets that way). An owner can be injected into the set after it's fetched (to change it or trick Maximo), but this is rarely good code.
Instead of getting a fresh set (no other ties or possible data caching) from the server in its own transaction, you might be best off getting the invoiceline set off of your current MBO. I don't know your exact use case, but generally you want to do something like this instead of getting a new set like you did. At the least, it will give your new set an "owner". You may even want to make the SQL a "relationship" instead of hard-coding it.
ilSetWhere = "ponum='" + mbo.getString("PONUM") + "' and positeid='" + mbo.getString("POSITEID") + "'"
ilSet = mbo.getMboSet("$TempInvoiceLineRelationship", "INVOICELINE", ilSetWhere)
ilMbo = ilSet.moveFirst()
I'm going from memory for this code, so I don't know if it is exactly correct. That form of "getMboSet" takes three parameters. The first is a relationship name. If Maximo finds that relationship name already "registered" from this starting object, it will ignore the next two parameters and use that relationship to get you that set. If it doesn't find that relationship "registered" it registers it for the scope of this code (so you can re-use it later in this code if you wanted). The second parameter defines what destination object to create the temporary relationship to. The third parameter defines the "where clause" of this temporary relationship.
Original Answer:
What is the error you are getting?
Also, you say you log "ilSet" after the "myMXServer.getMboSet..." line? That is going to cause Maximo to run the query and load the objects into the set at that point (it waits to run the query until it has to). As a result of that, you won't see the effects of your where clause change until you "reset()" the set.
I got a problem with this code:
string sql = "select distinct ruoli.c_tip_usr"
+ " from vneczx_ute_app_trn ruoli"
+ " join vnecyd_ent_prf ind"
+ " on ruoli.c_ent = ind.c_ent"
+ " where ruoli.c_app = :appCode"
+ " and ruoli.c_ute_mat = :matricola"
+ " and ind.t_des_ent = :indirizzo";
var ruoli = session.CreateSQLQuery(sql)
.SetString("appCode", Config.Configurator.Istance.ApplicationCode)
.SetString("matricola", user.Matricola)
.SetString("indirizzo", indirizzoCasella)
.List<string>();
This code is correctly executed, the query logged is correct, and the parameter passed correctly evaluated... but it doesn't return any result at all.
Copying the query from the debug console and executing it directly in an Oracle client application (SQL Developer), it gets 2 results (the results I expect to be right).
I found out that the problem is in the last parameter indirizzo, and should depend on the fact that it contains a special char # (indirizzo is an email address).
So I ended up using this solution:
string sql = "select distinct ruoli.c_tip_usr"
+ " from vneczx_ute_app_trn ruoli"
+ " join vnecyd_ent_prf ind"
+ " on ruoli.c_ent = ind.c_ent"
+ " where ruoli.c_app = :appCode"
+ " and ruoli.c_ute_mat = :matricola"
+ " and ind.t_des_ent = '" + indirizzoCasella + "'";
var ruoli = session.CreateSQLQuery(sql)
.SetString("appCode", Config.Configurator.Istance.ApplicationCode)
.SetString("matricola", user.Matricola)
.List<string>();
But it gives me thrills! Aren't the parameters in a query supposed to handle specifically this situation, and thus handle themselves situations with special char, and so on?
Why here a string concatenation works better that a parametric query?
Isn't there a way to force the NHibernate engine to escape some special char?
Update:
I found out how to solve this particular issue: usign the trim command on the field who raise the problem, the problem disappears.
So last line of my sql string now is:
+ " and trim(ind.t_des_ent) = :indirizzo";
I can't understand why it solves the problem thought. Not the field, nor the variable contains empty chars and copying th query on SQL Developer works in both way.
So we have some luck soving the problem, but we have no idea why now it works?
Any thoughts?
even I was facing the same issue, but your hint using TRIM for column saved my day. Since I was looking for a long time, but not able to figure it out.
Along with that, I was able solve my issue by doing the below changes as well:
We were using CHAR datatype some of the columns which used in the query where clause. This was causing the issue to fetch the data from NHibernate. We changed the data type of that column from CHAR to VARCHAR2 and even updated the data with actual size and removed the TRIM from Where clause, the TRICK WORKED!!!! :)
So, any one face this kind of issue, first check whether you are having any column with CHAR and then change to VARCHAR2.
But one more thing you have to remember is: if you are running your application from ASP.Net Development Server, close it and re-run your application. Since if the opening Asp.Net Development Server and if you make any changes to datatype that will NOT be refreshed in your oracle connection. So, better you close the ASP.Net Development server and then re run the application.
Hope my points will help somebody in future!!
Regards,
Sree Harshavardhana
You are not using parameters in a SQL query if you want SQL parameters use a SQL stored proc
I keep getting the same error: Missing Operator. I have looked over this code three times and cannot find it. Can someone with a keen eye please help?
WHERE ([Letter Status].[Letter_Status] = “Agreed” AND [Research].[Site] = 9)
OR ([Telephone Status].[Details]= “Agreed” AND [Research].[Site] = 9)
I'm not sure about that “”
Maybe is from this post, but change them to "" :
WHERE ([Letter Status].[Letter_Status] = "Agreed" AND [Research].[Site] = 9)
OR ([Telephone Status].[Details]= "Agreed" AND [Research].[Site] = 9)
Usually it is a misspelled table or field name, two spaces instead of just one, a space instead of "_", any missing letter or something like that.
Create a new query in MS Access and put the whole query in, then run it. The Access GUI most probably tells you more detailed what exactly is missing here.
I just created a couple of site columns and content types that reference them through VS2010. I updated one of the fields and then tried to redeploy, but after retracting, deploy failed because the site columns previously created were still there. I tried to delete them manually from the UI, and got an alert box with this message:
Site columns which are included in content types cannot be deleted.
Remove all references to this site
column prior to deleting it.
I dug around in SharePoint Manager and didn't find any references, so I used powershell to enumerate all the content types and lists looking for references to my site columns and found nothing.
I tried to delete using PowerShell like this:
$web.Fields.Delete("StartTime")
which resulted in this error:
Exception calling "Delete" with "1" argument(s): "Site columns which are included in
content types or on lists cannot be deleted. Please remove all instances of this site
column prior to deleting it."
At line:1 char:19
+ $web.Fields.Delete <<<< ("StartTime")
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : DotNetMethodException
Finally, a simple inspection of the columns in PowerShell shows the following:
Title Id CanBeDeleted ParentList Sealed ListsFieldUsedIn
----- -- ------------ ---------- ------ ----------------
Start Time OBE 6fa0d85b-9af1-408b-835f-d4c66536... True False {}
Time Tracker Tags 92bc866b-0415-45f0-b431-d4df69c4... True False {}
I'm experienced with MOSS 2007 and new to SP2010, but I've never seen this happen before. Anyone have any hints?
Your need to find and remove both the content types that use the site column and also any lists or libraries that use the site column you are trying to delete. Use PowerShell to get the site column object using something like this:
$column = $web.Fields[“Column Display Name”]
Then find all the places where it is used, using something like this:
$column.ListsFieldUsedIn()
which spits out two GUIDs -- the WebID and ListID -- of every place that uses this content type.
Below is a PowerShell script that loops over all the list GUIDs returned from ListFieldUsedIn() and then finds the subweb and list matching that GUID and prints out list name and subweb URL for each usage :
$site = Get-SPSite "http://sharepoint"
$rootweb = $site.rootweb
$siteColumnToRemove = "Column Display Name”
$sc = $rootweb.Fields[$siteColumnToRemove]
if ($sc)
{
write-host " Found Site Column '" $sc.Title "' in gallery" -ForegroundColor Gray
foreach( $listusage in $sc.ListsFieldUsedIn() )
{
$listID = $listusage.ListID
foreach ($subweb in $site.allwebs)
{
foreach ($list in $subweb.lists)
{
if ($list.ID -eq $listID)
{
write-host " Site Column '" $sc.Title "' used in list '" $list.Title "' in site '" $subweb.Url "'" -BackgroundColor Yellow -ForegroundColor Black
}
}
}
}
}
Happens to SharePoint 2010 too. Try looking at:
$field.AllowDeletion = $TRUE
$field.Update()
When I set that, seemed to work. Now I just can't replicate it, in order to prove my point. Typical.
I had this same problem and was able to delete using SharePoint Designer - not sure if anyone can validate this works for them.
It's been a while, and I've long since moved on from this problem, but I think that the final answer was that there were content types relying on a particular site column that weren't picked up by SPM.
I think once I retracted everything custom from the site, I was able to delete normally.
My guidance is that you should never delete a site column once it's in use. I've seen site collections become completely unusable because of issues trying to delete site columns or content types.
If you no longer need the site column, just hide it.