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
sugandhasugandha 

Inserting value into an object

Hi, 

     i want to insert value  calculated in a controller into a custom object how can i do this??? kindly help its urget

souvik9086souvik9086

Hi,

 

You can do like this

 

String calculatedValue{get;set;}

calculatedValue = //Your calculation;

 

ObjectName objectVariable = new ObjectName();

objectVariable.FieldName = calculatedValue;

insert objectVariable;

 

If this post is helpful please throw Kudos.If this post solves your problem kindly mark it as solution.

Thanks

 

Yoganand GadekarYoganand Gadekar

You approach should be following;

 

1. Retrieve your record in variable of that type(your object type)

2. Equate value to that field

3.Update the object varaible (you record)

 

For example if i want to update email field on contact record,

 

Contact con = [select id, email from contact where id =:'345tth65agte54rf33'];

con.email = 'Myneemail@gmail.com';

update con;

 

this will update contact whose id is "345tth65agte54rf33"

It completely depends on you how/from where yuo get your record.

 

thanks