web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Customer Service forum

Passing DateTime to Global Action using Javascript

(0) ShareShare
ReportReport
Posted on by

I am trying to pass DateTime parameter to global custom action using javascript. with no success. What is right way.

I have tried "typeName": "Edm.DateTime" and "Edm.DateTimeOffset" also tried "typeName": "Edm.String" (date formatted using javascript function .toJason() )

Code looks like following

act_testAction = function ( startDate) {

this.StartDate = startDate;

this.getMetadata = function () {
return {

boundParamter: null,
parameterTypes: {
"StartDate": { 
"typeName": "Edm.DateTime",
"structuralProperty": 1
}
},
operationType: 0, // 0 for action, 1 for function and 2 for CRUD
operationName: "act_test"
};

};

 

let requestObject = new act_testAction( sdate);

return await Xrm.WebApi.online.execute(requestObject);

Categories:
I have the same question (0)
  • Arun Vinoth Profile Picture
    11,615 Moderator on at

    You need to use formatted datetime using format("yyyy-MM-ddThh:mm:ss.sszzz")

    Refer this: community.dynamics.com/.../164537

  • Community Member Profile Picture
    on at

    Thanks, 

    I was trying to call actions using 

      Xrm.WebApi.online.execute(requestObject);

    I converted my login to using XMLHttpRequest and it works (Same date time value)

    i am curious to know if anyone has used  Xrm.WebApi.online.execute to call actions (especially date). Just wanted to understand where i went wrong...

    here is the code

    inc_testAction = function (firstEntityReference, secondEntityReference,  startDate) {

    this.first = firstEntityReference;
    this.second = secondEntityReference;
    this.StartDate = startDate;

    this.getMetadata = function () {
    return {
    boundParamter: null,
    parameterTypes: {
    "first ": {// Entity Reference
    "typeName": "mscrm.my_entityone",
    "structuralProperty": 5
    },
    "second": {// Entity Reference
    "typeName": "mscrm.myentitytwo",
    "structuralProperty": 5
    },
    "StartDate": { // Date
     "typeName": "Edm.DateTimeoffset",
     "structuralProperty": 1
    }
    },
    operationType: 0, 
    operationName: "my_Test"
    };
    };

    };


    let firstEntityReference= {
    "@odata.type": "Microsoft.Dynamics.CRM.my_entityone",
    "@inc_schedule.id": scheduleId
    };
    let secondEntityReference= {
    "@odata.type": "Microsoft.Dynamics.CRM.myentitytwo",
    "@inc_rotation.id": rotationId
    };

    //mynamespace.common.convertToLocalDate()

    //this function returns 

    // localDate.toJSON();

    var requestObject = new inc_testAction(firstEntityReference, secondEntityReference, mynamespace.common.convertToLocalDate(startDate)); /

    return await Xrm.WebApi.online.execute(requestObject);

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard > Customer Service

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans