问题
I am new Dynamics CRM. My project includes form submissions and validations. I am planning to build a product using a React with Redux frontend and a service from CRM.
What will be the best practice in CRM on Building CRM Web Resources Can anyone guide me?
https://github.com/sonomapartners/web-resources-with-react
import 'babel-polyfill';
import React from 'react';
import ReactDOM from 'react-dom';
import CaseSummary from './components/CaseSummary.jsx';
window.addEventListener('load', function onLoad() {
ReactDOM.render( <CaseSummary />,
document.getElementById("container") );
});
回答1:
- Get context:
- Add
ClientGlobalContext.js.aspx
in the in theindex.html
:<script type="text/javascript" src="ClientGlobalContext.js.aspx">
. ClientGlobalContext is the offical hook to Dynamics form context. - In the React
componentDidMount
life cycle, Addconst context = GetGlobalContext();
to get the context object. if you send data to the WebResource with the OpenWebResource(webResourceName, windowOptions, data), you can get the data in this way:JSON.parse(context.getQueryStringParameters().Data);
- Add
Intellisense: if you are using
TypeScript
use the d.ts (definition) file:///<reference path=Xrm.V9.d.ts/>
. you can get it here.Uplaod: WebRersource can't be
jsx
ortsx
type. After you compile your project you should only upload the bundled file (bundle.js).- Debug: If you want to debug your jsx/tsx file, you will need to use fiddler's AutoResponder to use the source map file. Here is an explanation.
来源:https://stackoverflow.com/questions/56622495/building-crm-web-resources-with-react