+ Start a Discussion
sathya82sathya82 

Date Problem In Custom Soap Webservice

HI,

 

        I develop a webservice i am getting the date 12/9/2013 format while i am inserting this date in oppoertunity object but the date which comes from thirdparty system is not inserting exactly.

 

  my code is for date insert.

 

  Opportunity o = new Opportunity()

  o.Name = rName// rName Which Coming from Third Party system

  o.CloseDate =  ocDate; // when i map like this means it not taking may i know i want to da any modifications

   the date which was given by third party system that data must be insert in sfdc

 

      insert 0;

 

 

cmoylecmoyle

I would suggest parsing the date to create a date object before assigning it to the CloseDate. Something like this:

 

//Assuming ocDate is the string value from third party system
//ocDate format (MM/dd/yyyy)
Date closeDate = Date.parse(ocDate);
Opportunity o = new Opportunity();
o.Name = rName;
o.CloseDate = closeDate;
insert o;

 

sathya82sathya82

@cmoyle

 

 

     When I used your code at that time it showing an error message

 

    Variable does not exist: Date at line 

 

    Date closeDate = Date.parse(req.ocDate); // error occuring point

   Opportunity o = new Opportunity();  

o.CloseDate = req.ocDate;
o.StageName =req.oStage;
insert o;

 

May i know where should i have to modify the code.