function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
FredoDevFredoDev 

How to Populate RecordType value from C#.net

Hi devs,

 

Can anybody give me a solution. I have the following code

 

sObject[] upserts = new o2bc__Item__c[1];

o2bc__Item__c upsertAccount = new o2bc__Item__c();

 upsertAccount.RecordType.Name ="Product/Parts";  -- Here i got obj reference issue - Can anyone tell how to populate        value for this
upsertAccount.Name = "SFG TEST";
upsertAccount.Rental__c = 150.00;
upsertAccount.Sell_Price__c = 250.00;
upsertAccount.Pricing__c = "Flat";
upsertAccount.Bill_Cycle__c = "Daily";

upserts[0] = upsertAccount;



try
{
int i = 0;
SaveResult[] upsertResults = SFService.create(upserts);
foreach (SaveResult result in upsertResults)
{

if (result.success)
{

MessageBox.Show("Updated Success");


}

Best Answer chosen by Admin (Salesforce Developers) 
Saurabh DhobleSaurabh Dhoble

You need to populate the "RecordTypeID" field - refer to the Salesforce SOAP API documentation.

You can get the recordtype from the "RecordType" object - Select Id, Name from RecordType.

 

Hope this helps.

All Answers

Saurabh DhobleSaurabh Dhoble

You need to populate the "RecordTypeID" field - refer to the Salesforce SOAP API documentation.

You can get the recordtype from the "RecordType" object - Select Id, Name from RecordType.

 

Hope this helps.

This was selected as the best answer
FredoDevFredoDev

Thank you very much Saurabh Dhoble.

 

Now i can able to populate the value. 

But the next problem is 

 

upsertAccount.Rental__c = 150.00; (Currency type)
upsertAccount.IsNeed__c = true;   (bool type)

 

I have tried with Convert.ToDouble & double.Parse same way to bool..

but its not showing any error and its not get population any idea.

 

Hi guys, finally i got the solution of my own.. i will share for you....

 

you have to set true to 

upsertAccount.Rental__cSpecified = true

 

this has to be given for  boolean, curreny, numeric types.. Happy Coding :)