IPP v3 Invoice QueryService not working with Skip/Take when using non-default fields - intuit-partner-platform

I'm trying to query invoices using the .NET IPP DevKit v3.
Following all the directions found on the documentation site, I can query invoices and add skip/take/order by/where/etc to the query when using ONLY default fields. But, as soon as I add non-default fields, skip/take/order by/where/etc does NOT seem to work.
Here's the error:
System.ArgumentException was unhandled
HResult=-2147024809
Message=Expression of type 'System.Collections.Generic.IEnumerable`1[<>f__AnonymousType0`3[Intuit.Ipp.Data.Invoice,Intuit.Ipp.Data.Line[],Intuit.Ipp.Data.LinkedTxn[]]]' cannot be used for parameter of type 'System.Linq.IQueryable`1[<>f__AnonymousType0`3[Intuit.Ipp.Data.Invoice,Intuit.Ipp.Data.Line[],Intuit.Ipp.Data.LinkedTxn[]]]' of method 'System.Linq.IQueryable`1[<>f__AnonymousType0`3[Intuit.Ipp.Data.Invoice,Intuit.Ipp.Data.Line[],Intuit.Ipp.Data.LinkedTxn[]]] Skip[<>f__AnonymousType0`3](System.Linq.IQueryable`1[<>f__AnonymousType0`3[Intuit.Ipp.Data.Invoice,Intuit.Ipp.Data.Line[],Intuit.Ipp.Data.LinkedTxn[]]], Int32)'
Source=System.Core
What am I missing here?
Code:
string AppToken = "your AppToken goes here";
string AppConsumerKey = "your AppConsumerKey goes here";
string AppConsumerKeySecret = "your AppConsumerKeySecret goes here";
string AccessToken = "your AccessToken goes here";
string AccessTokenSecret = "your AccessTokenSecret goes here";
string RealmCompanyId = "your RealmId goes here";
OAuthRequestValidator oauthValidator = new OAuthRequestValidator(AccessToken, AccessTokenSecret, AppConsumerKey, AppConsumerKeySecret);
ServiceContext context = new ServiceContext(AppToken, RealmCompanyId, IntuitServicesType.QBD, oauthValidator);
QueryService<Intuit.Ipp.Data.Invoice> qs = new QueryService<Intuit.Ipp.Data.Invoice>(context);
// This works...
var defaultQuery = qs.Select(c => c).Skip(0).Take(10).OrderBy(c => c.Id);
var defaultList = defaultQuery.ToList();
// This works...
var nonDefaultQuery = qs.Select(c => new { c, c.Line, c.LinkedTxn });
var nonDefaultList = nonDefaultQuery.ToList();
// This does NOT work!!
var nonDefaultQueryWithSkip = qs.Select(c => new { c, c.Line, c.LinkedTxn }).Skip(0).Take(10);
var nonDefaultListWithSkip = nonDefaultQueryWithSkip.ToList();

I tried on the API explorer-
Select *,Line.*, LinkedTxn.* FROM Invoice startPosition 1 maxResults 10 (which is your last query) and it works fine but not from .net sdk. I will double check this on the .net SDK and get back to you. Can you verify that you get the correct results on API explorer from this query?

This now works in the latest version (IppDotNetSdkForQuickBooksApiV3.2.0.0)
Here's an example:
QueryService<Intuit.Ipp.Data.Invoice> qs = new QueryService<Intuit.Ipp.Data.Invoice>(context);
string query = string.Format("SELECT *, Line.* FROM Invoice ORDERBY Id STARTPOSITION {0} MAXRESULTS {1}", startPos, pageSize);
var recs = qs.ExecuteIdsQuery(query);
foreach (Intuit.Ipp.Data.Invoice rec in recs)
{
// do stuff...
}
.

Related

Populating RITM Variables from a REST Call

I'm in the process of learning scripted REST API's. I have one that creates a REQ and RITM when the user does a POST. I'm having trouble populating variables from the rest post to the RITM. Below is my current code. Response is the RITM, Requester, and short description. I'm open to all suggestions, like I said I'm learning this on the fly, so if there is any glaring problems, I'm all ears. Thanks!
(function process(/*RESTAPIRequest*/ request, /*RESTAPIResponse*/ response) {
var cartId = GlideGuid.generate(null);
var cart = new Cart(cartId);
var item = cart.addItem('25409830135aa20099fc7e776144b0a0');
var rc = cart.placeOrder();
var req = request.getHeader('ContactEmployeeId');
var sdesc = request.getHeader('ShortDescription');
//return rc.number;
//gs.addInfoMessage(rc.number);
var num = rc.sys_id; //get sys ID of newly created request
var rnum = 0;
//using the request number, query the RITM table for related RITM
var u = new GlideRecord('sc_req_item');
u.addEncodedQuery('request='+num);
u.query();
while ( u.next() )
{
rnum = u.number;
}
response.setBody({
Requested_Item: rnum,
u_requester: req,
short_description: sdesc
});
response.setContentType('application/json');
})(request, response);
You can use the setVariable(ritm, variableName, value) method such as this.
var cartId = GlideGuid.generate(null);
var cart = new Cart(cartId);
var item = cart.addItem('25409830135aa20099fc7e776144b0a0');
// add your variables here to the item variable in your cart object
cart.setVariable(item, "comments", message);
cart.setVariable(item, "my_var_1", value1);
cart.setVariable(item, "my_var_2", value2);
// submit order
var rc = cart.placeOrder();

Tags are appearing in left of the document in embedded Signing using template

``code` DocuSignTK.Recipient recipient = new DocuSignTK.Recipient();
recipient.Email = signer_email; // This person will use embedded signing. If you have his
// email, supply it. If you don't, use a fake email that includes your
// ClientUserID. Eg embedded_signer_{ClientUserID}#your_company.com
recipient.UserName = signer_name;
recipient.ID = 1;
recipient.Type_x = 'Signer';
recipient.RoutingOrder = 1;
recipient.RoleName = 'Signer1';
// We want this signer to be "captive" so we can use embedded signing with him
recipient.CaptiveInfo = new DocuSignTK.RecipientCaptiveInfo();
recipient.CaptiveInfo.ClientUserID = signer_user_id; // Must uniquely identify the
// Create the recipient information
DocuSignTK.ArrayOfRecipient1 recipients = new DocuSignTK.ArrayOfRecipient1();
recipients.Recipient = new DocuSignTK.Recipient[1];
recipients.Recipient[0] = recipient;
DocuSignTK.ArrayOfTemplateReferenceRoleAssignment Roles = new DocuSignTK.ArrayOfTemplateReferenceRoleAssignment();
Roles.RoleAssignment = new DocuSignTK.TemplateReferenceRoleAssignment[1];
DocuSignTK.TemplateReferenceRoleAssignment role = new DocuSignTK.TemplateReferenceRoleAssignment();
role.RoleName = 'Signer1';
role.RecipientID = 1;
Roles.RoleAssignment[0] = role;
// Create the template reference from a server-side template ID
DocuSignTK.TemplateReference templateReference = new DocuSignTK.TemplateReference();
templateReference.Template = 'd0d80082-612b-4a04-b2a1-0672eb720491';
templateReference.TemplateLocation = 'Server';
templateReference.RoleAssignments = Roles;
// Construct the envelope information
DocuSignTK.EnvelopeInformation envelopeInfo = new DocuSignTK.EnvelopeInformation();
envelopeInfo.AccountId = account_Id;
envelopeInfo.Subject = 'Subject';
envelopeInfo.EmailBlurb = 'Email content';
// Make the call
try {
//DocuSignTK.EnvelopeStatus result = api_sender.CreateAndSendEnvelope(envelope);
// Create draft with all the template information
DocuSignTK.ArrayOfTemplateReference TemplateReferenceArray = new DocuSignTK.ArrayOfTemplateReference();
TemplateReferenceArray.TemplateReference = new DocuSignTK.TemplateReference[1];
TemplateReferenceArray.TemplateReference[0] = templateReference;
DocuSignTK.EnvelopeStatus result = api_sender.CreateEnvelopeFromTemplates( TemplateReferenceArray, recipients, envelopeInfo, true);
envelope_id = result.EnvelopeID;
System.debug('Returned successfully, envelope_id = ' + envelope_id );
} catch ( CalloutException e) {
System.debug('Exception - ' + e );
error_code = 'Problem: ' + e;
error_message = error_code;
} `code``
I am integrating Docusign for embedded signing. I am using SOAP API and used method CreateEnvelopeFromTemplates . Template I created is having some fields/Tabs. But once I open signing url these fields are located on side of the document instead of the location which I sent in template.
I have also assigned Role name for recipient but it is not working. Please help.
Click here to see screenshot
Here is the C# code to create an envelope from template using the DocuSign SOAP Api. Documentation here
string apiUrl = "https://demo.docusign.net/api/3.0/api.asmx";
string accountId = "Enter accountId"; //
string email = "Enter email";
string userName = "Enter intergrator key";
userName += email;
string _password = "Enter password";
var apiClient = new DocuSignTK.APIServiceSoapClient("APIServiceSoap", apiUrl);
apiClient.ClientCredentials.UserName.UserName = userName;
apiClient.ClientCredentials.UserName.Password = _password;
// Construct all the recipient information
var recipients = new DocuSignTK.Recipient[1];
recipients[0] = new DocuSignTK.Recipient();
recipients[0].Email = "recipientone#acme.com";
recipients[0].UserName = "recipient one";
recipients[0].Type = DocuSignTK.RecipientTypeCode.Signer;
recipients[0].ID = "1";
recipients[0].RoutingOrder = 1;
recipients[0].RoleName = "Signer1";
var roles = new DocuSignTK.TemplateReferenceRoleAssignment[1];
roles[0] = new DocuSignTK.TemplateReferenceRoleAssignment();
roles[0].RoleName = recipients[0].RoleName;
roles[0].RecipientID = recipients[0].ID;
// Use a server-side template -- you could make more than one of these
var templateReference = new DocuSignTK.TemplateReference();
templateReference.TemplateLocation = DocuSignTK.TemplateLocationCode.Server;
// TODO: replace with template ID from your account
templateReference.Template = "d0d80082-612b-4a04-b2a1-0672eb720491";
templateReference.RoleAssignments = roles;
// Construct the envelope information
DocuSignTK.EnvelopeInformation envelopeInfo = new DocuSignTK.EnvelopeInformation();
envelopeInfo.AccountId = " ";
envelopeInfo.Subject = "create envelope from templates test";
envelopeInfo.EmailBlurb = "testing docusign creation services";
// Create draft with all the template information
DocuSignTK.EnvelopeStatus status = apiClient.CreateEnvelopeFromTemplates(new DocuSignTK.TemplateReference[] { templateReference },
recipients, envelopeInfo, false);
I downloaded a template from production and uploaded in sandbox but once I recreated similar template in Sandbox only and used it's template ID in code then it is working perfectly. Apparently, There seems to be some issue with import template utility of Docusign.

How to tokenize a text in lucene 3.0.3

I need to translate this code from lucene.net 2.3.2 to 3.0.3.
This code works fine in 2.3.2 but in 3.0.3 the method tokenStream.Next() does not return a token but a boolean. What I need to understand is where to read the token object when next() returns true.
Analyzer analyzer = new StandardAnalyzer();
StringReader stringReader = new StringReader("the house id red");
TokenStream tokenStream = analyzer.TokenStream("", stringReader);
Token token = tokenStream.Next();
while (token != null)
{
System.Diagnostics.Debug.Write(token.TermText());
token = tokenStream.Next();
}
The TokenStreams in Lucene 3+ can now represent a whole set of values (called attributes) for each position in the stream. So you need to modify your example to be attribute aware...
var analyzer = new StandardAnalyzer(Lucene.Net.Util.Version.LUCENE_30);
var stringReader = new StringReader("the house id red");
var tokenStream = analyzer.TokenStream(string.Empty, stringReader);
var termAtt = tokenStream.GetAttribute<ITermAttribute>();
while (tokenStream.IncrementToken())
{
Console.WriteLine(termAtt.Term);
}

How to read the unit price of an Item with IPP DevKit

I've seen elsewhere how to set the UnitPrice on an Item, using the wiley and elusive Item1 field as Intuit.Ipp.Data.Qbd.Money. But how do I READ the unit price from the Item1 field? I can't cast it. The new operator doesn't work ("new ...Money(myItem.Item1)"). So how do I get the price?
I realize the DevKit will probably never be changed so this makes sense. But can we at least get some doc explaining all those strange "xxxItemxxx" fields?
ServiceContext context = new ServiceContext(oauthValidator, realmId, intuitServiceType);
DataServices commonService = new DataServices(context);
Intuit.Ipp.Data.Qbd.Item qbdItem = new Intuit.Ipp.Data.Qbd.Item();
Intuit.Ipp.Data.Qbd.Money unitPrice = new Intuit.Ipp.Data.Qbd.Money();
unitPrice.Amount = 22;
unitPrice.AmountSpecified = true;
qbdItem.Item1 = unitPrice;
IEnumerable<Intuit.Ipp.Data.Qbd.Item> qbdItemsResult = commonService.FindAll(qbdItem, 1, 10) as IEnumerable<Intuit.Ipp.Data.Qbd.Item>;
foreach (var itemResult in qbdItemsResult)
{
Intuit.Ipp.Data.Qbd.Money test1UnitPrice = itemResult.Item1 as Intuit.Ipp.Data.Qbd.Money;
}
You can use the above code for .Net.
Response XML of Item entity suggests that 'UntiPrice' is a top level tag.
I tried this usecase using java. PFB code.
QBItemService itemService = QBServiceFactory.getService(context,QBItemService.class);
items = itemService.findAll(context,1, 100);
for (QBItem item : items) {
System.out.println("Name - " + item.getName() + " UnitPrice - " + item.getUnitPrice().getAmount());
Can you please try the same in .Net and let me know if it works in the same way.
Intuit.Ipp.Data.Qbd.Money [ getAmount() ]
Thanks

Trying to insert QBO invoice with IPP.NET

I am attempting to insert an invoice into Quickbooks Online using IPP.NET. The problem seems to be in setting the item.
Here is a snippet of my VB code for the first line, which works fine...
Dim qboInvoiceLine1 as new intuit.ipp.data.qbo.invoiceline
qboInvoiceline1.desc="Desc1"
qboInvoiceLine1.amount=10
qboInvoiceLine1.AmountSpecified=True
If I add the following code for setting the item, I get an error forming the XML...
Dim items1 as List(Of Intuit.Ipp.Data.Qbo.Item)=New List(Of Intuit.Ipp.Data.Qbo.Item)
Dim item1 as new intuit.ipp.data.qbo.item
item1.id=new intuit.ipp.data.qbo.idtype
item1.id.value="1"
items1.add(item1)
qboInvoiceLine1.Items=items1.ToArray
I do not even understand why the item ID seems to be some kind of array or list of items. One source of documentation suggests there is an itemID property of the invoice line, but this does not seem to be the case. Can anyone give me code for setting the itemID for an invoice line?
ItemsChoiceType2[] invoiceItemAttributes = { ItemsChoiceType2.ItemId, ItemsChoiceType2.UnitPrice,ItemsChoiceType2.Qty };
object[] invoiceItemValues = { new IdType() { idDomain = idDomainEnum.QB, Value = "5" }, new decimal(33), new decimal(2) };
var invoiceLine = new InvoiceLine();
invoiceLine.Amount = 66;
invoiceLine.AmountSpecified = true;
invoiceLine.Desc = "test " + DateTime.Now.ToShortDateString();
invoiceLine.ItemsElementName = invoiceItemAttributes;
invoiceLine.Items = invoiceItemValues;
invoiceLine.ServiceDate = DateTime.Now;
invoiceLine.ServiceDateSpecified = true;
listLine.Add(invoiceLine);