2
votes

I have the following code to insert a record (I will be inserting 1000's). I get a successful insert but all of the numeric fields are EMPTY in salesforce. The one text field works fine ("Church of Randy") and appears in salesforce. Any ideas what I could be doing wrong?

  public void InsertTestRecord()
    {

        ChurchHist__c ch = new ChurchHist__c();


        ch.ChurchId__c = 9999;
        ch.ChurchName__c = "Church of Randy";
        ch.ReportYear__c = 2013;
        ch.ReportMonth__c = 08;
        ch.RegisteredMembers__c = 777;
        ch.ActiveMembers__c = 111;
        ch.InactiveMembers__c = 666;
        ch.UsersForMonth__c = 25;
        ch.ContribForMonth__c = 789.01;
        ch.ContribYTD__c = 200000.02;
        ch.AchContrib__c = 200000.00;
        ch.CcContrib__c = 0.02;
        ch.AchToCc__c = 0.12345;

        sObject[] s = new sObject[1];
        s[0] = ch;
        try
        {
            SaveResult[] saveResult = binding.create(s);

            if (saveResult[0].success)
            {
                Debug.Print("Success");
            }
            else
            {
                foreach (Error error in saveResult[0].errors)
                {
                    Debug.Print(error.statusCode.ToString());
                    Debug.Print(error.message);

                }
            }
        }
        catch (SoapException se)
        {
            Debug.Print(se.ToString());

        }

    }
1
Is there an error in the data types allowed? - KevinDTimm
All the data types I set up in salesforce are Number(18,0) for the integer values and Currency(16,2) for the Decimal ones. Except for last one I set up as a Percent(10,5). - Randy R
In my output window I get "Success" from my debug statement. - Randy R
From the outside looking in, there are no issues that jump out - sorry. - KevinDTimm
Thanks for looking and from examples I thought everything was ok. I've only used salesforce for about a week but have 15 years programming experience so it's probably something stupid I did in salesforce :) - Randy R

1 Answers

2
votes

You need to set the specified flags, e.g. numeric property has an associated specified flag that controls if the .NET soap engine will actually send that property over the wire, unfortuantly the setter for the property does not automatically set the specified flag. e.g.

ch.ChurchId__c = 9999;
ch.ChurchId__cSpecified = true;
ch.reportyear__c = 2013;
ch.reportyear__cSpecified = true;

The specified flags are a "feature" of the .NET soap system for certain types. (numbers & dates IIRC).