From bb62c8e19b65be99b66cbc54987ee7239b53a2dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20S=C3=A1nchez?= Date: Sat, 21 Nov 2020 18:26:59 +0100 Subject: [PATCH] Readonly (#17) - Added functionality for the no action readme tags Co-authored-by: Fernando Bo Gimenez --- .../ControlManifest.Input.xml | 8 +-- .../MultiselectRecords.tsx | 63 +++++++++++-------- MultiselectRecordsEntity/index.ts | 2 +- README.md | 2 +- 4 files changed, 42 insertions(+), 33 deletions(-) diff --git a/MultiselectRecordsEntity/ControlManifest.Input.xml b/MultiselectRecordsEntity/ControlManifest.Input.xml index a84c660..3af8890 100644 --- a/MultiselectRecordsEntity/ControlManifest.Input.xml +++ b/MultiselectRecordsEntity/ControlManifest.Input.xml @@ -1,6 +1,6 @@ - + SingleLine.Text @@ -22,6 +22,7 @@ + No action Pop up In the same window In a new window @@ -36,8 +37,7 @@ False - - + @@ -46,4 +46,4 @@ - \ No newline at end of file + diff --git a/MultiselectRecordsEntity/MultiselectRecords.tsx b/MultiselectRecordsEntity/MultiselectRecords.tsx index 1866383..22d8037 100644 --- a/MultiselectRecordsEntity/MultiselectRecords.tsx +++ b/MultiselectRecordsEntity/MultiselectRecords.tsx @@ -331,35 +331,44 @@ const getRecordsFromTextField = async () => { Number.parseFloat(version[0] + "." + version[1]) >= 9.1 && Number.parseFloat(version[2] + "." + version[3]) >= 0.15631 ) { - - if(props.openWindow.toLowerCase() == "in a new window") { - (Xrm.Navigation as any).openForm({ - entityName: logicalName, - entityId: id, - openInNewWindow: true - }); - }else if(props.openWindow.toLowerCase() == "in the same window") { - (Xrm.Navigation as any).openForm({ - entityName: logicalName, - entityId: id, - openInNewWindow: false - }); - } else { - (Xrm.Navigation as any).navigateTo( - { + switch (props.openWindow.toLowerCase()) + { + case "no action": + break; + case "in a new window": + (Xrm.Navigation as any).openForm({ + entityName: logicalName, + entityId: id, + openInNewWindow: true + }); + break; + case "in the same window": + (Xrm.Navigation as any).openForm({ + entityName: logicalName, + entityId: id, + openInNewWindow: false + }); + break; + default: + case "in a pop up": + (Xrm.Navigation as any).navigateTo( + { + entityName: logicalName, + pageType: "entityrecord", + formType: 2, + entityId: id, + }, + { target: 2, position: 1, width: { value: 80, unit: "%" } }, + ); + break; + } + } else { + if(props.openWindow.toLowerCase() != "no action") { + Xrm.Navigation.openForm({ entityName: logicalName, - pageType: "entityrecord", - formType: 2, entityId: id, - }, - { target: 2, position: 1, width: { value: 80, unit: "%" } }, - ); + }); } - } else { - Xrm.Navigation.openForm({ - entityName: logicalName, - entityId: id, - }); } } @@ -567,4 +576,4 @@ const getRecordsFromTextField = async () => { ); } -export default MultiselectRecords; \ No newline at end of file +export default MultiselectRecords; diff --git a/MultiselectRecordsEntity/index.ts b/MultiselectRecordsEntity/index.ts index 5f9ed52..6d1ba75 100644 --- a/MultiselectRecordsEntity/index.ts +++ b/MultiselectRecordsEntity/index.ts @@ -204,4 +204,4 @@ export class MultiselectRecordsEntity implements ComponentFramework.StandardCont // Add code to cleanup control if necessary ReactDOM.unmountComponentAtNode(this._container); } -} \ No newline at end of file +} diff --git a/README.md b/README.md index b81b84a..ab75f89 100644 --- a/README.md +++ b/README.md @@ -67,7 +67,7 @@ What have been the improvements with the previous version? 8. Header Visible (required)-> Set if the header will be visible in the list displayed. -9. Open Form Options (required) -> This allows you to choose how to open the record when you perform an onClick. Options are: Popup, New Window, Same Window. +9. Open Form Options (required) -> This allows you to choose how to open the record when you perform an onClick. Options are: Popup, New Window, Same Window or No Action. 10. Populated Field Visible (required)-> Set if the field that gets populated will be visible. **NOTE: As now it is a JSON I would suggest to always set is as False. (It is the first option to appear when you select the dropdown)**