Wednesday, July 10, 2013

UFT - Return formated Date


I needed to get current date in this specific format: 2013-07-10T10:03:45.285+03:00
then, make it available for future activities, so here is what I did:

1. Created a Custom Code activity "GetTodayDate".

2. Added a Result Output Property.
Name: Result
Type: String

3. Go to Events Tab -> Create a default handler... for ExecuteEvent


4. Add following code:

public void CodeActivity22_OnExecuteEvent(object sender, STActivityBaseEventArgs args)
        {
            string date = XmlConvert.ToString(DateTime.Now,XmlDateTimeSerializationMode.Local);                               
            CodeActivity22.Output.Result = date;
        }

5.  Result:


6. Now I can link the Result and use it in future activities.


No comments:

Post a Comment