Can't add TaxService to QBO with .NET SDK - intuit-partner-platform

How do I create a tax rate in QBO using API v3 and the TaxService resource? When I try to add it the same way as I would any other object, Visual Studio gives me this error: "The type 'Intuit.Ipp.Data.TaxService' cannot be used as type parameter 'T' in the generic type or method Intuit.Ipp.DataService.DataService.Add(T)'. There is no implicit reference conversion from 'Intuit.Ipp.Data.TaxService' to 'Intuit.Ipp.Data.IEntity'."
Here's the code:
Intuit.Ipp.Data.TaxService ts = new Intuit.Ipp.Data.TaxService();
// Populate fields here...
DataService ds = new DataService(ServiceContext);
Intuit.Ipp.Data.TaxService newTs = ds.Add<Intuit.Ipp.Data.TaxService>(ts);

Use GlobalTaxService endpoint and JSON format only. Try this code:
GlobalTaxService taxSvc = new GlobalTaxService(context);
Intuit.Ipp.Data.TaxService taxCodetobeAdded = new Data.TaxService();
taxCodetobeAdded.TaxCode = "taxC_" + Guid.NewGuid().ToString("N");
QueryService<TaxAgency> taxagency = new QueryService<TaxAgency>(context);
TaxAgency taxagencyResult = taxagency.ExecuteIdsQuery("select * from TaxAgency").FirstOrDefault<TaxAgency>();
List<TaxRateDetails> lstTaxRate = new List<TaxRateDetails>();
TaxRateDetails taxdetail1 = new TaxRateDetails();
taxdetail1.TaxRateName = "taxR1_" + Guid.NewGuid().ToString("N");
taxdetail1.RateValue = 3m;
taxdetail1.RateValueSpecified = true;
taxdetail1.TaxAgencyId = taxagencyResult.Id.ToString();
taxdetail1.TaxApplicableOn = TaxRateApplicableOnEnum.Sales;
taxdetail1.TaxApplicableOnSpecified = true;
lstTaxRate.Add(taxdetail1);
TaxRateDetails taxdetail2 = new TaxRateDetails();
taxdetail2.TaxRateName = "taxR2_" + Guid.NewGuid().ToString("N");
taxdetail2.RateValue = 2m;
taxdetail2.RateValueSpecified = true;
taxdetail2.TaxAgencyId = taxagencyResult.Id.ToString();
taxdetail2.TaxApplicableOn = TaxRateApplicableOnEnum.Sales;
taxdetail2.TaxApplicableOnSpecified = true;
lstTaxRate.Add(taxdetail2);
//TaxRateDetails taxdetail3 = new TaxRateDetails();
//taxdetail3.TaxRateName = "rate298";
//taxdetail3.TaxRateId = "2";
//lstTaxRate.Add(taxdetail3);
taxCodetobeAdded.TaxRateDetails = lstTaxRate.ToArray();
Intuit.Ipp.Data.TaxService taxCodeAdded = taxSvc.AddTaxCode(taxCodetobeAdded);

Related

Apex Test Class failing on second asserEquals statement

Test Class failing on asserEqual:
I am trying to use this Test Class to test a isBefore && isInsert or IsUpdate Trigger but the test is failing on second assertEquals statement (end of the code, trying to compare return of SOQL Query:
I don't know why this is taking because I am doing a few simple inserts to test my Trigger.
Complete code:
#isTest
private class Test_Triggers{
static testMethod void Test_Triggers() {
Account acc = new Account();
acc.Name = 'sacasac';
insert acc;
Account contateste0 = new Account();
contateste0.Name = 'GRANITOS E MARMORES MACHADO LTDA EPP';
contateste0.Phone = '(27)3727-2929';
insert contateste0;
Contact contatoTeste = new Contact();
contatoTeste.FirstName = 'TITANIUM';
contatoTeste.LastName = 'TITANIUM';
contatoTeste.Phone = '3329-4053';
contatoTeste.MobilePhone = '27999970208';
contatoTeste.Email = 'gmmcontabil#gmail.com';
contatoTeste.AccountId = contateste0.Id;
insert contatoTeste;
Case novoCaso = new Case();
novoCaso.Subject = 'assunto';
novoCaso.Description = 'obs';
novoCaso.AccountId = contateste0.Id;
novoCaso.ContactId = contatoTeste.Id;
novoCaso.Origin = 'Portal';
insert novoCaso;
Opportunity novaOpp = new Opportunity();
novaOpp.AccountId = contateste0.Id;
novaOpp.Amount = 4200;
novaOpp.Name = '4200';
novaOpp.StageName = 'Pré_Oportunidade';
novaOpp.CloseDate = Date.today();
insert novaOpp;
Id idMeta = Schema.SObjectType.Meta__c.getRecordTypeInfosByName().get('CORE').getRecordTypeId();
Id idMeta2 = Schema.SObjectType.Meta__c.getRecordTypeInfosByName().get('NOVO').getRecordTypeId();
Meta__c meta01 = new Meta__c();
meta01.Data__c = Date.today();
meta01.Id_Usuario__c = UserInfo.getUserId();
meta01.Id_Conta__c = contateste0.Id;
meta01.RecordTypeId = idMeta;
meta01.Valor__c = 53161;
insert meta01;
System.assertEquals(53161, meta01.Valor__c);
Ordem_de_venda__c ordem = new Ordem_de_venda__c();
ordem.Oportunidade__c = novaOpp.Id;
ordem.Conta_Principal__c = acc.Id;
ordem.Pagador__c = acc.Id;
ordem.Data_de_vencimento__c = System.today().addDays(2);
ordem.Id_Meta__c = meta01.Id;
ordem.Tipo__c = 'Serviço';
insert ordem;
List<AggregateResult> aggregateOrdensVenda = [SELECT Id_Meta__c, sum(Valor_faturado__c) total, sum(VlrFor__c) forecast FROM Ordem_de_venda__c WHERE Id_Meta__c =:meta01.Id GROUP BY Id_Meta__c];
//This is failing because SOQL s returning nothing
system.assertEquals(1,aggregateOrdensVenda.size());
}
}```

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.

PSI update resource custom field with lookup table (Project Server)

Can someone show me a code to update a enterprise resource custom field with lookup table ? Already ran the internet looking for some sample code but did not succeed.
You can create and update a custom field with a lookup table using the below code . But we can not update or delete builtin custom fields
var projContext = new ProjectContext(projectServerUrl);
CustomFieldCollection CustomField = projContext.CustomFields;
EntityTypes Entitytype = projContext.EntityTypes;
LookupTableCollection lookupTables = projContext.LookupTables;
projContext.Load(CustomField);
projContext.Load(Entitytype);
projContext.Load(lookupTables);
projContext.ExecuteQuery();
CustomFieldCreationInformation NewfieldInfo = new CustomFieldCreationInformation();
NewfieldInfo.Id = new Guid();
NewfieldInfo.Name = "The Name";
NewfieldInfo.Description = "The Description";
NewfieldInfo.IsWorkflowControlled = true;
NewfieldInfo.IsRequired = true;
NewfieldInfo.IsEditableInVisibility = false;
NewfieldInfo.IsMultilineText = false;
LookupTable lookuptable = lookupTables.ToList().Find(x => x.Name == "LookupTableName");
projContext.Load(lookuptable);
projContext.ExecuteQuery();
NewfieldInfo.LookupTable = lookuptable;
NewfieldInfo.EntityType = Entitytype.ProjectEntity;
NewfieldInfo.FieldType = CustomFieldType.TEXT;
projContext.CustomFields.Add(NewfieldInfo);
projContext.CustomFields.Update();
projContext.ExecuteQuery();

How to connect SSRS into ReportViewer 2010 at Runtime?

I have my codes as bellow and it shows me empty page after compiling:
ReportViewerControl = new ReportViewer();
ShowZoomControl="false"
ReportViewerControl.ServerReport.ReportServerUrl = new Uri(ReportServerUri);
ReportViewerControl.ServerReport.ReportPath = Model.Report.ReportPath;
ReportViewerControl.Visible = true;
ReportViewerControl.ShowReportBody = true;
ReportViewerControl.ShowParameterPrompts = false;
ReportViewerControl.ProcessingMode = ProcessingMode.Remote;
ReportViewerControl.ShowZoomControl = false;
ReportViewerControl.ShowBackButton = false;
ReportViewerControl.InteractivityPostBackMode = InteractivityPostBackMode.AlwaysAsynchronous;
ReportViewerControl.Height = 780;
ReportViewerControl.Width = 800;
IList<ReportParameter> FishSpeciesParameters = new List<ReportParameter>();
ReportParameter SPStatus = new ReportParameter();
SPStatus.Name = "SPStatus";
if (Model.Report.ID == 8)
SPStatus.Values.Add("T,E,C");
ReportParameter FishCode = new ReportParameter();
FishCode.Name = "FishCode";
FishCode.Values.Add("11");
FishSpeciesParameters.Add(SPStatus);
FishSpeciesParameters.Add(FishCode);
ReportViewerControl.ServerReport.SetParameters(FishSpeciesParameters);
ReportViewerControl.ServerReport.Refresh();
Any Ideas to view SSRS Report into ReportViewer on Fly?
maily you just need to set ServerReport.ReportServerUrl to something like this:
"http://localhost:8080/ReportServer"
and the ReportPath to
reportFolder + "/" + reportName;

How to create an ArcMap Layer from a ArcGIS Map Service

I would like to add an ILayer created from an ArcGIS Server Map service to an IMap with ArcObjects, but don't see how to do it.
I am getting an IMapServer3 with the following code, where mapName = the map service:
serverContext = som.CreateServerContext(mapName, "MapServer");
IServerObject serverObject = serverContext.ServerObject;
IMapServer3 mapServer = (IMapServer3)serverObject;
It looks like I can get an ILayer from an IMapServerGroupLayer, but it looks like the IMapServerGroupLayer is looking for a different connection type than I am using.
If you have an example of getting an ILayer from a Map Service, your assistance is appreciated.
This is what worked...
private static void GetLayerFromMapServerLayer()
{
IAGSServerConnectionName servConnName = new AGSServerConnectionNameClass();
IPropertySet props = new PropertySetClass();
props.SetProperty("machine", "server");
servConnName.ConnectionProperties = props;
IAGSServerConnectionFactory pAGSServerConnectionFactory = new AGSServerConnectionFactoryClass();
IAGSServerConnection pAGSConnection = pAGSServerConnectionFactory.Open(props, 0);
IAGSEnumServerObjectName pEnumSOName = pAGSConnection.ServerObjectNames;
IAGSServerObjectName pSOName = pEnumSOName.Next();
while (pSOName != null)
{
if (pSOName.Name == "Base_Map")
break;
pSOName = pEnumSOName.Next();
}
IName pName = (IName)pSOName;
IMapServer mapServer = (IMapServer)pName.Open();
IMapServerLayer msLyr = new MapServerLayerClass();
msLyr.ServerConnect(pSOName, mapServer.DefaultMapName);
IMapServerGroupLayer group = (IMapServerGroupLayer)msLyr;
ILayer msLayer = (ILayer)msLyr;
//return msLayer;
MapDocument mapDoc = new MapDocumentClass();
mapDoc.Open(#"F:\~mkoneya~2011_82_13_58_30.mxd");
IMap myMap = mapDoc.get_Map(0);
myMap.AddLayer(msLayer);
mapDoc.Save();
}