Giter VIP home page Giter VIP logo

salesforcemagic's People

Contributors

benbenwilde avatar hougaard avatar lventre avatar michael-shattuck avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

salesforcemagic's Issues

DateTime conversions yield inconsistent results because of UTC

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:

  1. Create an SObject with a date
  2. Set the date field to a local date
  3. Save the SObject
  4. Query the SObject by ID to get a copy of the object
  5. Compare dates

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.

Readonly Attribute

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.

Malformed query

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.

Library returns only first batch of query

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

Profile259 build

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

Add count feature

It would be great to be able to easily retrieve the count for particular CustomObjects (without performing a count on the list returned).

No handling for ApiFault classes, ExceptionCode enum

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:

https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_calls_concepts_core_data_objects.htm#i1421571

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.

client.PerformCrudOperation doesn't exist?

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!

Error encountered using client.Insert<T>() - Organization ID: id value of incorrect type

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...

Error message

errormessage

Code encountering the error

codeencounteringerror

Definition of the Account Dto

definition of dsoaccountsf

The following code using the Microsoft types generated from the WSDL works

codeusingsoapwsdl

Kind regards,
Craig.

Unsupported content type: text/xml

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; }
        }

Implement better raw query and raw data mapping.

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.

Some fields are valid to supply when inserting, but are not allowed to be updated.

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.

Metadata query?

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.

Add exception handling for 400 Bad Request

Currently the follow exception is not handled:

<error xmlns="http://www.force.com/2009/06/asyncapi/dataload">
    <exceptionCode>[code]</exceptionCode>
    <exceptionMessage>[message]</exceptionMessage>
</error>

Salesforce has disabled TLS 1.0

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.