Filling a Word template with data from Exact Online query returns itgendps155: Publication failed - exact-online

When filling a Word template through SQL on Exact Online the following error occurs:
Publication failed.
Context:
value-of expression
16Hjjhhhasdhfjhasjhfjha;jsfhsahfdahskj;dhkhsdkjhskjhkKashdhasdjhjsahdjhjsadJashdkaskjdjsakdkjhDocumentnrKlantnrOffertedatum<invantive:value-of expression="$F{qtk.quotationnumber}" ***/><invantive:foreach> <invantive:value-of expression="$F{qtk.orderaccountcode}" /></invantive:foreach><invantive:foreach> <invantive:value-of expression="$F{qtk.quotationdate}
The location of the error is indicated by the marker '***'.
Evaluation of expression "$F{qtk.quotationnumber}" failed.
Cannot find field with the name 'quotationnumber'. Check that you have inserted a surrounding repeating block and that the field exists in that block.
The underlying SQL of the block in Composition for Word is:
select qtk.quotationnumber
, qtk.versionnumber
, qtk.quotationdate
, qtk.orderaccountcode
, acc.name
, acc.addressline1
, acc.postcode
, acc.city
, acc.countryname
, acc.phone
, acc.fax
, acc.vatnumber
, itm.code
, qtl.itemdescription
, qtl.notes
, qtl.quantity
, qtl.netprice
, qtl.amountdc
, qtl.vatpercentage*100
from exactonlinerest..Quotations Qtk
left
outer
join exactonlinerest..Accounts Acc
on acc.id = qtk.orderaccount
left
outer
join exactonlinerest..QuotationLines Qtl
on qtl.quotationid = qtk.quotationid
and qtl.quotationnumber = $P{P_OFFERTE}
and qtl.versionnumber = $P{P_VERSIE}
left
outer
join exactonlinerest..Items Itm
on itm.id = qtl.item
where qtk.status = 40
and qtk.quotationnumber = $P{P_OFFERTE}
and qtk.versionnumber = $P{P_VERSIE}
The SQL returns a list of quotations and their lines and items (articles) from Exact Online.
The content of the document is:
I've tried various options, but the error keeps appearing. What am I doing wrong?

I guess you want to create a Word document with quotation header information, plus some quotation lines (just like traditional Order -> Order Lines master - detail table).
In this case I would first recommend splitting the query in two pieces:
One outer Composition block with query that retrieves the quotation information.
An inner Composition block with query that handles the quotation lines from Exact Online, including article information.
But that is not your current. In your Word template you have no repeating block specified. This is the area that should be repeated for each and every occurrence of a row in a block. You can easily insert a repeating block by clicking on Building Block in the Modeler menu. And then choosing the right block and then "Create repeating block".
As an alternative, you can also put
<invantive:foreach block="BLOCK-CODE">
before the text and other tags that you want to repeat in the resulting Word document including layout and pictures.
And put
</invantive:foreach>
after it.
The <invantive:foreach> that you already are not containing all tags. The <invantive:value-of expression="$F{qtk.quotationnumber}"/> is not contained. Also, the other foreaches are not at usable position. Better is to put the repeater outside the table.

Related

ComboBox Access Match on ID but Display Category

I am working on a project but have run into a wall with Access's combo-boxes. I've attached an image so things (hopefully) make more sense when I describe my situation.
I have two combo-boxes on a form, the left one is called cmb_body_system, and the right one is called cmb_icd9code.
What I am trying to do is have the left box display three options, the three from the body_system_type table: infectious, circulatory, respiratory. From there, the second box will display the matching description in the ICDLight table column titled icd9Description.
I have gotten as far as getting the left box to display the bodyID's associated with each matching Icd9Description, but I can't get further than that. The VBA that I have on these is:
Private Sub cmb_body_system_AfterUpdate()
cmb_icd9code.RowSource = "SELECT ICD9Description FROM ICDLight WHERE ICDLight.bodyID = " & Me.cmb_body_system & ";"
End Sub
And as you can see, it's working, but I want to go that one step further and don't know what/how to search for this exactly. I mean, I don't even know how inaccurate/accurate the title is for that matter.
I think you need to rephrase your question. From your question title, I think this is what you need.
Select your cmb_body_system
Go to property sheet
Under Format tab:
Column Count = 2
Column Widths = 0cm; <- there is a semicolon
Under the Data Tab
Bound Column = 1
Row Source Type = Table/Query
Row Source = "SELECT * FROM BODY_SYSTEM_TYPES"
Now your combobox will show "bodysystem" as display text and Bodyid as value

Working Around SQL Replace Wildcards

I know that I cannot use a wildcard in a MySQL replace query through phpMyAdmin. But, I need some kind of workaround. I'm very open to ideas. Here's the skinny:
I have about 2,000 pages in a MySQL database that need to have image URL's updated. Some are local, some are hotlinked. Each one is different, the URL lengths vary, the image on the page and the new image are unique per page id number, and each one occurs at a different spot in the page.
I basically need to do the following:
UPDATE pages SET body = replace(body, 'src=\"%\"', 'src=\"http://newdomain/newimage.jpg\"') WHERE id="{page_number}"
But I know that the 'src=\"%\"' component doesn't jive.
So I fall at the feet of your collective knowledge to come up with some way to take the src="%" and replace it with a set URL for a set page id number. Thanks in advance.
If there's only one image per page, a quick solution would be like this:
UPDATE pages
SET
body = CONCAT(
SUBSTRING_INDEX(body, 'src="', 1),
'src=\"http://newdomain/newimage.jpg\"',
SUBSTRING(
SUBSTRING_INDEX(body, 'src="', -1)
FROM LOCATE('"', SUBSTRING_INDEX(body, 'src="', -1))+1)
)
WHERE
id="{page_number}" AND
body NOT LIKE '%<img%<img%';
First SUBSTRING_INDEX extract the body part at the left of src=", the last two nested SUBSTRING_INDEX extracts the body part at the right of the first " next to src=".
Last check is a very dirty check to make sure that only one image is present in the string. It could fail under some circumstances, but it might help.
My suggestion would be to build a table with your replace strings that would look like this:
page_id replace
1 src="..."
Then you can update across a JOIN like this
UPDATE pages AS p
INNER JOIN replace AS r
ON p.page_id = r.page_id
SET p.body = REPLACE(p.body, CONCAT('src="', SUBSTRING_INDEX(SUBSTRING_INDEX(p.body, 'src="', -1), '"', 1), '"', r.replace);
This would replace the last occurrence anything of format src="..." with a new value in same format, so this would work for all records with a single src value.

SQL query - Replace/Move some parts of content

I need to update about 2000 records in MySQL
I have a column 'my_content' from table 'my_table' with the folowing value
Title: some title here<br />Author: John Smith<br />Size: 2MB<br />
I have created 3 new columns (my_title, my_author and my_size) and now I need to separate the content of 'my_content' like this
'my_title'
some title here
'my_author'
John Smith
'my_size'
2MB
As you can imagine the title, author and size are always different for each row.
What I'm thinking is to query the following, but I'm not great at SQL queries and I'm not sure what the actually query would look like.
This is what I'm trying to do:
Within 'my_content' find everything that starts with "title:..." and ends with "...<br />au" and move it to 'my_title'
Within 'my_content' find everything that starts with "thor:..." and ends with "...<br />s" and move it to 'my_author'
Within 'my_content' find everything that starts with "ize:..." and ends with "...<br />" and move it to 'my_size'
I just don't know how to write a query to do this.
Once all the content is in the new columns, I can just find and delete the content that's not needed any more, for example 'thor:' , etc.
You can use INSTR to find the index of your delimiters and SUBSTRING to select out the part you want. So, for instance, the author would be
SUBSTR(my_content,
INSTR(my_content, "Author: ") + 8,
INSTR(my_content, "Size: ") - INSTR(my_content, "Author: ") - 8)
You'd need a bit more work to trim the <br/> and any surrounding whitespace.
Please try the below:
SELECT SUBSTRING(SUBSTRING_INDEX(mycontent,'<br />',1),LOCATE('Title: ',mycontent)+7) as mytitle,
SUBSTRING(SUBSTRING_INDEX(mycontent,'<br />',2),LOCATE('Author: ',mycontent)+8) as myauthor,
SUBSTRING(SUBSTRING_INDEX(mycontent,'<br />',3),LOCATE('Size: ',mycontent)+6) as mysize
FROM mytable;

sql to get tags in linking table

I have a query that I made to return all the tags in a set with the tags in a concatenated list, but I'm trying to determine how to write a query that will return the same results but only for those items with a specific tag.. list talks by tag, if you will. Logically, if I add a 'where tbl_tag.tag_id=3', it only lists that specific tag in the group.. I want it to be able to still list all of them. Possibly multiple queries are the answer but I'm curious if it can be done with one.
SELECT tbl_talks.*,
GROUP_CONCAT(tbl_tag.tag_name ORDER BY tbl_tag.tag_name) AS tags
FROM tbl_talks
LEFT JOIN tbl_linking_talk_tag
ON tbl_talks.talk_id = tbl_linking_talk_tag.talk_id
LEFT JOIN tbl_tag
ON tbl_linking_talk_tag.tag_id = tbl_tag.tag_id
GROUP BY tbl_talks.talk_id
The quick, hackish solution would be to wrap your entire query in an outer query, and only return records containing the appropriate tag using WHERE tags LIKE '%....%. This is fragile, because there's always the chance that you'll have one tag (e.g. "berry") that is container within another (e.g. "strawberry"). There are ways around this, but they're not pretty and not very SQLish.
A slightly more correct (and equally untested!) solution would be to add the original query as a subquery in your WHERE clause:
WHERE EXISTS
(
SELECT
1
FROM
tbl_talks
LEFT JOIN tbl_linking_talk_tag
ON tbl_talks.talk_id = tbl_linking_talk_tag.talk_id
LEFT JOIN tbl_tag
ON tbl_linking_talk_tag.tag_id = tbl_tag.tag_id
WHERE
tbl_tag.tag_id IN (the, tag_ids, you, want)
)
There might be a simpler built-in way of doing this in MySQL, but I don't know it.

How do I solve column width problems in a SSRS Tablix?

I'm creating a simple report from Microsoft Dynamics CRM. When I pull in the following dataset:
SELECT FQD.productidname
, FQD.NEW_PRICEBREAKS
, FQD.NEW_WEEKSARO
, ltrim(rtrim(FP.NEW_PRODUCTNAME)) AS NewProductDesc
, FQD.productdescription
, FQD.quoteid
, FQD.quantity
, FQD.productiddsc
, FQD.baseamount
, FQD.lineitemnumber
, FQD.priceperunit
, FQD.extendedamount
, ISNULL(FP.productnumber, '') AS productnumber
, ISNULL(FQD.uomidname, '-') AS Unit
, FQD.tax AS Tax
, FQD.volumediscountamount * FQD.quantity AS Discount
, FQD.manualdiscountamount AS MDiscount
, FQD.quotedetailid
, FQD.crm_moneyformatstring
, FQD.NEW_PRICEPERUNIT
, FQD.NEW_PRICEPERUNIT_BASE
FROM FilteredQuoteDetail FQD
LEFT OUTER JOIN
FilteredProduct FP
ON FQD.productid = FP.productid
WHERE (FQD.quoteid = #CRM_QuoteId)
The NewProductDesc field is too wide. If I shorted it in design view, it still comes out too wide in the presentation. I think the field is coming out that wide because the database field probably has a bunch of blank spaces at the end of every description. I could not find a way to force that field in the Tablix not to grow horizontally, so I attempted to remedy it in the dataset by replacing the NewProductDesc line with:
ltrim(rtrim(FP.NEW_PRODUCTNAME)) AS NewProductDesc
However, that has no effect either.
Can anyone suggest why this behavior is occuring? Can anyone tell me how I can force the field not to grow horizontally?
I think in your case it is better to set width staticly e.g: 1.25in
But if you want to use percentage and Trim() didn't work check SPACE() and see which number do you get? -this method gives you count of spaces in the string.-
If you found too many space in the report then Trim it in your Database Query