michael-shattuck / salesforcemagic Goto Github PK
View Code? Open in Web Editor NEWEasy access to various Salesforce APIs.
Home Page: http://michael-shattuck.github.io/SalesforceMagic/
License: MIT License
Easy access to various Salesforce APIs.
Home Page: http://michael-shattuck.github.io/SalesforceMagic/
License: MIT License
When using DateTime fields, input DateTime are saved in the yyyy-MM-ddTHH:mm:ssZ format, but if the DateTime isn't converted to UTC before saving, the value of the same object returned by a SOQL query will yield a different date. This is because the expected input and output of Salesforce is UTC, and a conversion to UTC doesn't take place automatically on the input, but is automatically converted to local time on the output.
The workaround, of course, would be to convert all dates to UTC before saving, and expect local times on the return.
It would be nice to have the expected input match the expected output from Salesforce. Thus, if I send in a local time, the conversion would automatically set the correct UTC date, and then a subsequent SOQL query would return the same local time.
Simple test would be to:
The test will fail if there isn't an explicit conversion after step 4 to convert the queried date back to UTC.
This does beg a larger look at a larger design feature. The automatic conversion at the back end is somewhat problematic once you start working with dates outside of your local time. Thus, if you serialize an object from another system that has a different timezone, then the date has to be set to an offset of your local time, and the test above would fail again. The work around for this, of course, would be to convert the dates to prior to a save and after a query, but a similar problem of tedium exists.
Having the ability to retrieve data, but ignore it when upserting/updating. Perhaps a readonly attribute or an ignore attribute with read, push and both options.
when testing against, login is being rejected. I have checked UID/PWD and set IsSandbox to false with not luck
client.AdvancedQuery<Account>(a => !a.IsDeleted, 50);
produces a malformed query: "Account WHERE IsDeleted = True != True LIMIT 50"
Should just be "Account WHERE IsDeleted != True LIMIT 50"
Update: client.AdvancedQuery<Account>(a => a.IsDeleted != true, 50);
produces the same result.
It seems like nullable datetime fields are not mapping correctly.
Currently when querying with an apostrophe, for example, the query fails because the apostrophe is not escaped.
Hi, first of all - good library, thanks!
It looks like you have not implemented yet pagination for big queries. SF returns only 200 records and the flag that says that not all data have been returned with token for next set.
Also, I noticed that query with expression does not produce correct request. I filtered my records by two numbers:
finalResult = this.sfMagicClient.Query(t => t.Week_c == weekNumber).ToList();
and got error that saying that the query is wrong:
select * from ProductTelemetry_C where Week_c =
Evgeny
Michael,
I would really like to try out your package in a Visual Studio 2015 Shared Portable Library but cannot install it because it does not contain a target for '.NETPortable, Version=4.5, Profile=Profile259'. Did not really want to attempt a pull request for this as I have not done this before but do you think you could rebuild the package to target this version of the framework.
Thanks in advance,
Mark
When adding a batch to a job fails no indication is made.
It would be great to be able to easily retrieve the count for particular CustomObjects (without performing a count on the list returned).
263d77f
SalesforceMagic/SalesforceClient.cs line 311
Currently, exceptions thrown by the Salesforce (e.g. ApiFault sub-classes) are not being serialized and returned as faults. Only the exceptionMessage is being returned. This is fine for most things, but there are a few errors that would be nice to trap for, if possible (for example, INVALID_SESSION_ID as a result of a token expiration...or invalidation). Yes, we could parse the exceptionMessage, but we could easily deserialize the response based to an ApiFault (which provides the message and the exceptionCode (which is an enum...with standard values and can be deserialized by name). This would beat using magic strings.
Yes, I'm aware that the ExceptionCode enum will vary by configuration, but there is a full list of both ExceptionCodes and StatusCodes here:
We could add a generic error if the exception code isn't available, or doesn't deserialize (as Salesforce adds new items to that list).
In any event, I figured it might be worth exploring.
Hi there.. I'm just starting to tinker. Although I'm able to retrieve attachments, I'm unable to upload them.
In your example code:
SalesforceResponse response = client.PerformCrudOperation(attachments, CrudOperations.Insert);
It doesn't seem client.PerformCrudOperation is defined. Can you help me understand how to do a simple attachment upload? (SOAP is fine, I don't need BulkAPI just yet).
I tried SalesforceResponse response = client.Crud(attachment); but still won't work.
Sorry to be such a NOOB.
Thanks!
Hi Michael,
Thank you for making this amazing library available. I've installed the nuget package and have had great success with the GetSession(), Count() and Query() methods against my Salesforce sandbox.
I've run into an error though, when I try and insert a new record. Salesforce is complaining about the Organization ID being of the wrong type, although I am inserting an Account record which doesn't seem to have an Organization Id in it.
Could you provide some pointers on how to fix this error?
Here's some screenshots of what I'm seeing and the code I'm using...
Kind regards,
Craig.
I get the error "Unsupported content type: text/xml" when trying to utilize the bulk api.
It happens at the client.CreateBulkJob<Account>
method.
(I had to add response = response ?? xml.GetElementsByTagName("exceptionMessage")[0];
to your httpClient.PerformRequest method to see the contents of the error)
Any ideas?
var username = "<redacted>";
var password = "<redacted>";
var securityToken = "<redacted>";
SalesforceConfig config = new SalesforceConfig()
{
Username = username,
Password = password,
SecurityToken = securityToken,
Environment = "https://redacted--sandbox.cs15.my.salesforce.com",
IsSandbox = true,
};
Account[] accounts = new[]
{
new Account { Name = "Account 3" }, new Account { Name = "Account 4" }
};
using (SalesforceClient client = new SalesforceClient(config))
{
// single SOAP crud operations work!
/*var crudResponse = client.Crud<Account>(new CrudOperation<Account>()
{
Items = accounts,
OperationType = CrudOperations.Insert
});*/
// bulk api calls do not :(
JobInfo jobInfo = client.CreateBulkJob<Account>(new JobConfig()
{
Operation = BulkOperations.Insert,
ConcurrencyMode = ConcurrencyMode.Parallel
});
//BatchInfo batchInfo = client.AddBatch(accounts, jobInfo.Id);
SalesforceResponse jobCloseResponse = client.CloseBulkJob(jobInfo.Id);
}
[SalesforceName("Account")]
public class Account : SObject
{
public string Id { get; set; }
public string Name { get; set; }
}
Currently the SalesforceClient returns lists of mapped generic objects (supporting both predicates and raw queries). It would be nice to have the ability to retrieve raw/dynamic data. Perhaps primitive types, anonymous objects, and associative arrays.
I ran into this issue when creating an object via Insert
and then updating it later via Update
. One of the properties is an id pointing to a parent object, and the property cannot be edited after its created (this is just because of a setting on the object in salesforce). Maybe we could add another attribute like SalesforceInsertOnly
or something similar to deal with this situation. I don't know if thats the best way to go about it or not. Right now I just set it to null when updating and that works ok for now.
I know the REST API allows for query of metadata. Is there something similar available for SOAP? If so, it'd be nice query for this info in this library.
Currently the follow exception is not handled:
<error xmlns="http://www.force.com/2009/06/asyncapi/dataload">
<exceptionCode>[code]</exceptionCode>
<exceptionMessage>[message]</exceptionMessage>
</error>
Now that Salesforce has disabled TLS 1.0 should
ServicePointManager.SecurityProtocol be set to 1.1 or greater by default? Perhaps in the SalesforceClient object.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.