In the qbXML ItemQuery request , how do I get the description for a service item? - qbxml

I am creating a tool that will synchronize our production database with QuickBooks (QB). I am trying to get a list of all the items in QB using ItemQuery and I want to get the description of each item as well. However, it seems that different types of items have different ways of specifying the description. Using IncludeRetElement, I am able to get the SalesDesc for ItemInventoryRet, but I am struggling with getting the description for ItemServiceRet (and a few others, but I think if I can figure this one out, I will be able to figure out the others).
Here is my request...
<?qbxml version="12.0"?>
<QBXML>
<QBXMLMsgsRq onError="stopOnError">
<ItemQueryRq requestID="2">
<IncludeRetElement>ListID</IncludeRetElement>
<IncludeRetElement>Name</IncludeRetElement>
<IncludeRetElement>FullName</IncludeRetElement>
<IncludeRetElement>ParentRef</IncludeRetElement>
<IncludeRetElement>SalesAndPurchase_SalesDesc</IncludeRetElement>
<IncludeRetElement>SalesOrPurchase_Desc</IncludeRetElement>
<IncludeRetElement>ItemDesc</IncludeRetElement>
<IncludeRetElement>SalesDesc</IncludeRetElement>
</ItemQueryRq>
</QBXMLMsgsRq>
</QBXML>
And here is the response I'm getting (shortened for clarity)...
<QBXML>
<QBXMLMsgsRs>
<ItemQueryRs requestID="2" statusCode="0" statusSeverity="Info" statusMessage="Status OK">
<ItemServiceRet>
<ListID>240000-1071531214</ListID>
<Name>Delivery</Name>
<FullName>Delivery</FullName>
</ItemServiceRet>
<ItemInventoryRet>
<ListID>270000-1071524193</ListID>
<Name>1/2" Line</Name>
<FullName>Irrigation Hose:1/2" Line</FullName>
<SalesDesc>1/2" Vinyl Irrigation Line</SalesDesc>
</ItemInventoryRet>
<ItemGroupRet>
<ListID>1E0000-934380927</ListID>
<Name>Walkway</Name>
<ItemDesc>Walkway lighting</ItemDesc>
</ItemGroupRet>
</ItemQueryRs>
</QBXMLMsgsRs>
</QBXML>
According to the documentation (pick ItemQuery from the dropdown), the description I think I want is ItemServiceRet > ORSalePurchase > SaleOrPurchase > Desc. The request includes one way I've tried, but I've tried quite a few other ways as well...
<IncludeRetElement>ORSalesPurchase:SalesOrPurchase:Desc</IncludeRetElement>
<IncludeRetElement>ORSalesPurchase.SalesOrPurchase.Desc</IncludeRetElement>
<IncludeRetElement>ORSalesPurchase_SalesOrPurchase_Desc</IncludeRetElement>
<IncludeRetElement>SalesOrPurchase:Desc</IncludeRetElement>
<IncludeRetElement>SalesOrPurchase.Desc</IncludeRetElement>
<IncludeRetElement>SalesOrPurchase_Desc</IncludeRetElement>
<IncludeRetElement>Desc</IncludeRetElement>
So the question is, how do you retrieve sub elements in qbXML queries?
I have found that if I remove all the IncludeRetElements, I do get the values. But I would like to learn how to only get the data I care about. We have a HUGE QB database so this could be a major performance issue if I have to get everything.
As a note, I switched to using QBFC10Lib instead of creating the XML myself hoping it would help me solve this issue, but it didn't. I am still having the exact same issue. I'm guessing that an answer to one will resolve both qbXML and QBFC.

I figured it out. You have to add each level separately, like this...
<?qbxml version="12.0"?>
<QBXML>
<QBXMLMsgsRq onError="stopOnError">
<ItemQueryRq requestID="2">
<IncludeRetElement>ListID</IncludeRetElement>
<IncludeRetElement>Name</IncludeRetElement>
<IncludeRetElement>FullName</IncludeRetElement>
<IncludeRetElement>ItemDesc</IncludeRetElement>
<IncludeRetElement>SalesDesc</IncludeRetElement>
<IncludeRetElement>ORSalesPurchase</IncludeRetElement>
<IncludeRetElement>SalesOrPurchase</IncludeRetElement>
<IncludeRetElement>SalesAndPurchase</IncludeRetElement>
<IncludeRetElement>Desc</IncludeRetElement>
</ItemQueryRq>
</QBXMLMsgsRq>
</QBXML>
I had tried this earlier, but I think I missed a level. Anyway, hopefully this answer will help somebody else from wasting half their day :).

Related

Protractor Implementation in Angular2 without using ids

I have application in Angularjs2, and developers have not been using ids into it. Now I have to implement the Protractor on same application. Is there anyway to implement the Protractor without using "absolute XPath"?
Thanks in advance!
Please find a huge range of locator-possibilities on the official Protractortest API Page
Every element on a page needs to be uniquely identifiable... else the page wouldn't work, no matter which technology. Therefore with the help of any of the above provided locator-possibilities you'll always find the element you're looking for.
And there is never a need for XPath, except for this only one. (though there is an parentElementArrayFinder introduced in the meantime, so not even that one exception is valid anymore)
UDPATE
If you could use XPath, you can for sure use CSS-Locators.
Here some examples for locators:
$('div.class#id[anyAttribute="anyValue"] div.child.somewhere-below-div-point-class')
element(by.cssContainingText('div[data-index="2"]', 'select this option'))
Or as a specific example the "Learn More" of the "Tree List" section of https://js.devexpress.com/ :
treeListSection = element(by.cssContainingText('div.tab-content h2', 'Tree List')).getDriver();
learnMoreBtn = treeListSection.element(by.cssContainingText('a.tab-button','Learn More'));
learnMoreBtn.click();
Those are just examples, but there is always a way to do it.
If you provide some example-HTML in your Question, I can direct you towards a solution.
UPDATE 2
For getting the Parent Web Element, one could use getDriver() as well

RESTful urls for restore operation from a trash bin

I've been implementing a RESTful web service which has these operations:
List articles:
GET /articles
Delete articles (which should remove only selected articles to a trash bin):
DELETE /articles
List articles in the trash bin:
GET /trash/articles
I have to implement an operation for restoring "articles" from "/trash/articles" back to "/articles".
And here is the question. Ho do you usually do it? What url do I have to use?
I came up to the 2 ways of doing it. The first is:
DELETE /trash/articles
But it feels strange and a user can read it like "delete it permanently, don't restore".
And the second way is
PUT /trash/articles
Which is more odd and a user will be confused what this operation does.
I'm new to REST, so please advice how you do it normally. I tried to search in google but I don't know how to ask it right, so I didn't get something useful.
Another option could be to use "query params" to define a "complementary action/verb" to cover this "special condition" you have (given that this is not very easily covered by the HTTP verbs). This then could be done for example by:
PUT /trash/articles?restore=true
This would make the URI path still complaint with REST guideline (referring to a resource, and not encoding "actions" - like "restore") and would shift the "extra semantics" of what you want to do (which is a very special situation) to the "query parameter". "Query params" are very commonly used for "filtering" resources in REST, not so much for this kind of situation... but maybe this is a reasonable assumption given your requirements.
I would recommend using
PUT /restore/articles
or
PUT /restore/trash/articles
Late answer but, in my opinion, the best way is to change the resource itself.
For instance:
<article is_in_trash="true">
<title>come title</title>
<body>the article body</body>
<date>1990-01-01</date>
</article>
So, in order to remove the article from Trash, you would simple use PUT an updated version of the article, where is_in_trash="false".

TYPO3 : no updated newsletter with direct_mail and scheduler

This is my 1st question on this forum... So, please, be indulgent !
I'm using TYPO3 4.7.11 (PHP 5.3.3) with extension direct_mail 3.1.1 for the intranet site of a non-profit firm.
My problem (maybe connected to Bug #51583 : http://forge.typo3.org/issues/51583) is that, after numerous tests and attempts, it seems impossible to have an updated version of a page saved as draft for newsletter in an automatic scheduler driven way : the same newsletter is produced with the same informations that were already there on the day it was first created and saved.
The specific page used for newsletter includes a content element 'Menu/Sitemap' with 'Recently updated pages' as 'Menu type'. It has been saved as 'draft (for recurring sendings)' in Direct Mail.
The scheduler contains these 2 tasks with recurring type :
- Direct Mail: Create Mail from Draft (direct_mail)
- Direct Mail: Mailing Queue (direct_mail)
Note : the manual way is fully functional and the newsletter produced is really updated. Same with option "Testmail - Simple" !
So, my problem seems to be linked to the automatic scheduled mailing ! It looks as if the newsletter draft has turned into a freezed snapshot of a specific moment and that Typo3 is unable to update/recalculate this page when invoked in scheduler mode.
On the web, I saw reported problems that could be related like "When mails get sent via the scheduler the same subject is used for all sendings ( https://review.typo3.org/21313 )" and "Adding hooks when sending direct mails via scheduler ( forge.typo3.org/issues/48994 )", but these issues seem to be fixed with direct_mail 3.1.1 version.
I made these observations and, in my opinion, there is some relevancy :
1.There is no domain proposed in the 'Domain of internal links' drop-down list in 'Set default values for mail content fetching options' in Direct Mailer, and yet I have a single record in sys_domain table with a domain name (with no protocol and no final slash). Is there a reason why this record is not considered good, or isn't it the right table ? (uid=3, pid, tstamp, crdate, cruser_id, hidden, sorting, prepend_params and forced=0, redirectHttpStatusCode=301, domain_name=site.subdomain.domain, redirectTo=)
2.In the Typo 3 Log, I get this systematic error message for user _cli_scheduler#LIVE :
Core: Error handler (BE): PHP Warning: Invalid argument supplied for
foreach() in
...typo3conf/ext/direct_mail/Classes/Scheduler/MailFromDraft.php line
125.
The concerned part of MailFromDraft.php is this function : initializeHookObjects
...
/*
* Initializes hook objects for this class
*
* #return void
*/
function initializeHookObjects() {
foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['direct_mail']['mailFromDraft'] as $hookObj) {
$hookObjectInstance = t3lib_div::getUserObj($hookObj);
if (is_object($hookObjectInstance) && ($hookObjectInstance instanceof x_directmail_Scheduler_MailFromDraftHook)) {
$this->hookObjects[] = $hookObjectInstance;
}
}
}
...
I'm not sure of understanding very clearly the origin and the use of the hook Object... (in spite of this interesting article by Robert Lemke : typo3.org/documentation/article/how-to-use-existing-hooks-in-your-own-extension/ )
3.Nothing like the apparently requested GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['direct_mail']['mailFromDraft'] seems to exist in TYPO3_CONF_VARS (Global configuration).
Can anybody give me an advice or a clue about what's going on and why I can't get a weekly updated newsletter with the scheduler ? I feel a bit confused !
Thanks in advance for any suggestion or solution (if a miracle is possible).
Greetings.
P-H SILLIAU
I've read about this issue before, but couldn't remember where.
Googling "direct_mail draft (for recurring sendings)" helped.
Try this bug: http://forge.typo3.org/issues/4421
User Markus says:
Things work fine, when you set a domain-record in your system and
select it in the direct_mail settings!
If you don't have a domain-record and specify it in the direct_mail
setup you're able to send normal newsletters, but if you try the
draft-functionality it won't work because the getUrlBase function in
class.tx_directmail_static.php returns an unsuable URL to the System
so it can't use the fetchHTML($file) and quits - therefore not
replacing the old draft contents created when starting the first time.
I don't really get why this works the first time you set up the draft
though....
So setting up the domain-record is a work-around that works.
I hope it does!
Probably, you will find more related topics.
Else, workarounds would be
re-considering the task. As it's a NPO intranet, maybe requirements are not that required suddenly, if asked again :-)
setting up a custom notification tool that only does that precise job.
To put an end to this problem, after many attempts (and informations gleaned from the internet), here is the solution we finally used in our specific case to make the newsletter work :
1st. We created a record in table sys_domain. This was a recurrent instruction in the manual and the forums, and it was IMHO legitimate.
Important : note that the redirectTo field had to remain empty, due to global malfunction of the site if filled (whatever we put in it like /, /var/www/sitename, ...)
2nd. All images, CSS, JS included in template had to be hardcoded (i.e. http ://site/fileamin/images/xxx.png for instance). If we didn't do that, the result would have been an abort in the production of the newletter : Not Found... Maybe, by digging a bit deeper, should we be able to find a parameter we forgot or neglected in some way to solve this issue...
3rd. In the newsletter template TS setup, we added these 2 parameters :
mod.web_modules.dmail.use_domain=[uid of sys-domain]
config.absRefPrefix = / (in order to get rid of PHP DOCUMENT_ROOT (or TYPO3_DOCUMENT_ROOT ?) otherwise wrongly present in all generated links.)
The result is now a well dynamically-generated newsletter, the date is OK, all links are correct and realUrl-compliant (no ../index.php?id=nnn) .... and you know what ?... We're happy ! :-)
Hope it will help !
Many thanks to everybody who answered (Markus, Urs...) or even thought of a possible solution...
P-H Silliau

Trying to figure out what {s: ;} tags mean and where they come from

I am working on migrating posts from the RightNow infrastructure to another service called ZenDesk. I noticed that whenever users added files or even URL links, when I pull the xml data from RightNow it gives me a lot of weird codes like this:
{s:3:""url"";s:45:""/files/56f5be6c1/MUG_presso.pdf"";s:4:""name"";s:27:""MUG presso.pdf"";s:4:""size"";s:5:""2.1MB"";}
It wasn't too hard to write something that parses them and makes normal urls and links, but I was just wondering if this is something specific to the RightNow service, or if it is a tag system that is used. I tried googling for this but am getting some weird results so, thought stack overflow might have someone who has run into this one.
So, anyone know what these {s ;} tags are called and if there are any particular tools to use to read them?
Any answers appreciated!
This resembles partial PHP serialized data, as returned by the serialize() call. It looks like someone may have turned each " into "", which could prevent it from parsing properly. If it's wrapped with text like this before the {s: section, it's almost definitely PHP.
a:6:{i:1;a:10:{s:
These letters/numbers mean things like "an array with six elements follows", "a string of length 20 follows", etc.
You can use any PHP instance with unserialize() to handle the data. If those double-quotes are indeed returned by the API, you might need to replace :"" and ""; with " before parsing.
Parsing modules exist for other languages like Python. You can find more information in this answer.

Show all posts from category X with the same taxonomy term as current post

I already have this almost working, with a neat snippet someone helped me with. Currently though its displaying all posts regardless of category or post type with the same taxonomy term as the current post. I would like to change it so I can specify which category it should loop in the posts from.
This is what the code looks like:
http://pastebin.com/pM8aFPQ9
I realise this is probably pretty easy to do, but I dont know where in this code I should specify the categories or how I should write to do that. Can anyone help me with this?
I used your code to solve the same problem and I filtered the posts with info from:
http://codex.wordpress.org/Class_Reference/WP_Query
Using the info on that page, in the $args that you specify, you can add 'post_type' => array('custom_post_type_01', 'custom_post_type_02');
You could also specify which categories to include (or exclude) using this code:
'category_name' => 'category';
You can find more info on the page above and you can essentially filter your posts using lots of different parameters. Hope this helps!