Skip to main content

Notifications

Announcements

No record found.

Supply chain | Supply Chain Management, Commerce
Answered

Action input required failure error on get-customer data action call

Posted on by 15

Getting "Action Input Creation Failure" error while trying to call a get-customer action on definition file. Need help!

{
    "$type": "contentModule",
    "dataActions": { 
        "customerDataAction": {
            "path": "@msdyn365-commerce-modules/retail-actions/dist/lib/get-customer",
            "runOn": "server"
        }
    },  

}

  • Komal Humane Profile Picture
    Komal Humane 15 on at
    RE: Action input required failure error on get-customer data action call

    Hi Sam,

    The CORS error resolved now. Thanks for your advise.

    Regarding mock data, Yes I have updated the token, name, account number and email address in user context as I get from e-commerce site by sign in.

    But still the API url showing empty string like retail-server/Commerce/Customers('')?api-version=7.3

    Also, now I am getting below error related to channel.

    pastedimage1648038077339v1.png

    I have re-checked Channel ID in .env file that I get as record Info in retail server as per the document.

    Can you please help me to fix these errors?

    Thanks,

    Komal

  • Verified answer
    Sam Jarawan Profile Picture
    Sam Jarawan on at
    RE: Action input required failure error on get-customer data action call

    If you're seeing a CORS issue, i'm going to assume you are trying to run your e-commerce SDK against a tier 1 Retail server environment is that correct?  If so they document covers some troubleshooting steps you can try: docs.microsoft.com/.../debug-tier-1

    For testing you should mock the data as shown here : docs.microsoft.com/.../test-page-mock

    As an example i created following mock page:

    {

       "exception": null,

       "pageRoot": {

           "id": "core-root_0",

           "typeName": "core-root",

           "modules": {

               "body": [

                   {

                       "id": "default-page_0",

                       "typeName": "default-page",

                       "modules": {

                           "primary": [

                               {

                                   "id": "ProductFeature__0",

                                   "typeName": "product-feature",

                                   "config": {

                                       "imageAlignment": "left",

                                       "buttonText": "Buy Now",

                                       "productIds": "68719490621"

                                   }

                               },

                               {

                                   "id": "ProductFeature__1",

                                   "typeName": "product-feature",

                                   "config": {

                                       "imageAlignment": "right",

                                       "productIds": "68719498121",

                                       "buttonText": "Buy Now"

                                   }

                               }

                           ]

                       }

                   }

               ]

           }

       },

       "renderingContext": {

           "gridSettings": {

               "xs": {

                   "w": 767

               },

               "sm": {

                   "w": 991

               },

               "md": {

                   "w": 1199

               },

               "lg": {

                   "w": 1599

               },

               "xl": {

                   "w": 1600

               }

           },

           "staticContext": {

               "staticCdnUrl": "/_scnr/"

           },

           "user": {

               "token": "MY_TOKEN",

               "isAuthenticated": true,

               "signInUrl": "dev.fabrikam.com/.../signin",

               "signOutUrl": "dev.fabrikam.com/.../signout",

               "signUpUrl": "dev.fabrikam.com/.../signup",

               "editProfileUrl": "dev.fabrikam.com/.../editprofile",

               "signinName": "NAME",

               "firstName": "FIRST_NAME",

               "lastName": "LAST_NAME",

               "tenantId": "",

               "customerAccountNumber": "ACCOUNT_NUMBER",

               "name": "NAME",

               "emailAddress": "MY_EMAIL_ADDRESS"

           },

           "locale": "en-us"

       },

       "statusCode": 200

    }

    You should go to your e-commerce site, sign in and copy/replace above the token, name fields, account number and email address. Now the API call to get customer info will use the data from the user context.

    Hope that helps.

    Sam

  • Komal Humane Profile Picture
    Komal Humane 15 on at
    RE: Action input required failure error on get-customer data action call

    Hi Sam,

    Thanks for the quick response.

    Yes I was getting this error in development cycle and I tried creating page Mock for user context.

    It somewhat fixed the issue, after running page Mock url localhost:4000/page, I am able to see API Url in console but with below errors:

    pastedimage1647526834755v3.png

    As you can see, I am getting CORS Policy error, do I need to add any additional settings in any file? Can you help me with that please.

    Also, The API Url retail-server/.../Customers('') passing empty account number in console.

    I have updated User Customer Account Number in below files:

    PageMock - Customer Page

    src -> Mocks - json file

    Please guide me for how to pass account number using get-customer data action in commerce react.

    I am new to commerce React.

    Thanks,

    Komal

  • Sam Jarawan Profile Picture
    Sam Jarawan on at
    RE: Action input required failure error on get-customer data action call

    Hi Komal,

    If you are seeing a problem in the development cycle using this data action, i'll provide some guidance.

    If you examine the source code for the data action (located at the \node_modules\@msdyn365-commerce-modules\retail-actions\src\get-customer.ts),  you may notice that the user input comes from the requestContext as shown in below code:

    const createInput = (inputData: ICreateActionContext<IGeneric<IAny>>): GetCustomerInput => {

       const { user, apiSettings } = inputData.requestContext;

       if (!user.token || !user.isAuthenticated) {

           throw new Error('[getCustomer][createInput]: User is not Authenticated.');

       }

       return new GetCustomerInput(apiSettings);

    };

    This means to test locally you'll need to use a page mock that mocks the user context so that the data action sees it as signed in as explained in the following documentation topic: https://docs.microsoft.com/en-us/dynamics365/commerce/e-commerce-extensibility/test-page-mock#simulate-the-signed-in-state

    Next also make sure your module is using the proper return data type in the module data.ts file as shown below, this is the variable that is used for the return data for the data action and the name must match the name used in your module definition file. 

    import { AsyncResult, Customer} from '@msdyn365-commerce/retail-proxy';

    export interface IProductFeatureData {
        customer: AsyncResult<Customer>;
    }
    I hope this helps,
    Sam
  • Sam Jarawan Profile Picture
    Sam Jarawan on at
    RE: Action input required failure error on get-customer data action call

    Komal,

    How are you testing this and seeing the error, is the error in a deployed environment or a development environment?

    thanks,

    Sam

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans