Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion NNDropdown/ControlManifest.Input.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<manifest>
<control namespace="Controls" constructor="NNDropdown" version="0.0.94" display-name-key="NNDropdown" description-key="NN Relation converted into a Multiselect Dropdown" control-type="standard">
<control namespace="Controls" constructor="NNDropdown" version="0.0.95" display-name-key="NNDropdown" description-key="NN Relation converted into a Multiselect Dropdown" control-type="standard">
<!--external-service-usage node declares whether this 3rd party PCF control is using external service or not, if yes, this control will be considered as premium and please also add the external domain it is using.
If it is not using any external service, please set the enabled="false" and DO NOT add any domain below. The "enabled" will be true by default.
Example1:
Expand Down
1 change: 1 addition & 0 deletions NNDropdown/interface.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export interface Setting {
relationShipEntityName : string;
targetEntityName: string;
targetEntityFilter: string;
isSelfReference : boolean;
}

export interface EntityReference {
Expand Down
22 changes: 19 additions & 3 deletions NNDropdown/operations.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@ export async function _currentOptions(context: ComponentFramework.Context<IInput
const fetchXml: string =
`<fetch>
<entity name="${setting.relationShipEntityName}" >
<filter>
<condition attribute="${setting.primaryEntityName}id" operator="eq" value="${setting.primaryEntityId}" />
<filter type="or">
<condition attribute="${setting.primaryEntityName}id${setting.isSelfReference?"one":""}" operator="eq" value="${setting.primaryEntityId}" />
${setting.isSelfReference?`<condition attribute="${setting.primaryEntityName}idtwo" operator="eq" value="${setting.primaryEntityId}" />`:""}
</filter>
</entity>
</fetch>`;
Expand All @@ -54,7 +55,20 @@ export async function _currentOptions(context: ComponentFramework.Context<IInput
let currentOptions: Array<string> = new Array;

currentOptionsSet.entities.forEach(entity => {
currentOptions.push(entity[`${setting.targetEntityName}id`]);
if (setting.isSelfReference) {
if (entity[`${setting.targetEntityName}idone`]
// If entity1 is not the current record
&& (entity[`${setting.targetEntityName}idone`] !== setting.primaryEntityId
// or if both entity1 and entity2 are the current record (record linked to itself)
|| (entity[`${setting.targetEntityName}idone`] === setting.primaryEntityId && entity[`${setting.targetEntityName}idtwo`] === setting.primaryEntityId)))
currentOptions.push(entity[`${setting.targetEntityName}idone`]);

// If entity2 is not the current record
else if (entity[`${setting.targetEntityName}idtwo`] && entity[`${setting.targetEntityName}idtwo`] !== setting.primaryEntityId)
currentOptions.push(entity[`${setting.targetEntityName}idtwo`]);

} else if (entity[`${setting.targetEntityName}id`])
currentOptions.push(entity[`${setting.targetEntityName}id`]);
});

return currentOptions;
Expand All @@ -71,6 +85,8 @@ export function _proccessSetting(context: ComponentFramework.Context<IInputs>) {
relationShipEntityName: context.parameters.relationshipentityname.raw ? context.parameters.relationshipentityname.raw : "",
targetEntityName: context.parameters.targetentityname.raw ? context.parameters.targetentityname.raw : "",
targetEntityFilter: context.parameters.targetentityfilter.raw ? context.parameters.targetentityfilter.raw : "",
// Relationship structure is different when entity refers back to itself
isSelfReference: (context as any).page.entityTypeName === context.parameters.targetentityname.raw,
}
return setting;
}
Expand Down