-
-
Save andrew-grischenko/bce9896ee736d4db699fea336bf10a11 to your computer and use it in GitHub Desktop.
... | |
export class SomeComponent implements ComponentFramework.StandardControl<IInputs, IOutputs> { | |
private has_been_reset: boolean; | |
... | |
public init(context: ComponentFramework.Context<IInputs>, notifyOutputChanged: () => void, state: ComponentFramework.Dictionary, container:HTMLDivElement) | |
{ | |
this.has_been_reset = false; | |
... | |
} | |
... | |
public updateView(context: ComponentFramework.Context<IInputs>): void | |
{ | |
if(context.parameters.Reset.raw && !this.has_been_reset){ | |
this.has_been_reset = true; | |
// do the clean up logic here | |
... | |
} else | |
// Technically, this will be done on ANY change of a property, which we don't care about as long as | |
// it's also done on setting of the Reset property | |
this.has_been_reset = false; | |
... | |
} | |
... |
<?xml version="1.0" encoding="utf-8" ?> | |
<manifest> | |
<control ...> | |
<property name="Reset" display-name-key="Reset" description-key="Reset from start" of-type="TwoOptions" usage="input" required="false" default-value="false"/> | |
... | |
</control> | |
</manifest> |
// Declare in a code (on screen visible or something like that) a dummy reset variable | |
Set(DummyResetVariable, false); | |
// Bind your control's Reset property to a dummy reset variable | |
// In the Component's inspector set value of the property Reset to | |
DummyResetVariable | |
// Now when you need to reset a control, set the dummy variable | |
Set(DummyResetVariable, true); | |
Set(DummyResetVariable, false); |
Hi SPB21,
Could you clarify please "isn't available to set" - so is it not displayed in the inspector and not available to read either or just read-only?
Also, as another suggestion, would you try another name, not Reset but Reset2? I haven't checked for a while, but wondering if MS introduced "Reset" property into the basic component model? Just a guess.
Andrew, i've updated the property name to be:
<property name="resetControl" display-name-key="resetControl" description-key="Reset from start" of-type="TwoOptions" usage="input" required="false" default-value="false"/>
.
When i go to the Power App and look at my control properties i can see 'resetControl':
But when i try to set the property via a button OnSelect, it isnt available and i get the following error:
Ok, two things
In the sample screen, why do you try to set the value of another variable from the value of the controls property? It’s declared as input, not output.
Would you try
Set( editRequestAddress.resetControl, true); Set( editRequestAddress.resetControl, false);
?
Otherwise if you do need to read the control value try set usage=“bound” as mentioned here https://docs.microsoft.com/en-us/powerapps/developer/component-framework/manifest-schema-reference/property
I see now. Sorry, it will not work and my bad publishing incorrect information. We can't set the property directly like that in PowerApps, we can set variables only. So, I've updated the gist as below, please let me know if it makes sense and works eventually for you.
// Declare in a code (on screen visible or something like that) a dummy reset variable
Set(DummyResetVariable, false);
// Bind your control's Reset property to a dummy reset variable
// In the Component's inspector set value of the property Reset to
DummyResetVariable
// Now when you need to reset a control, set the dummy variable
Set(DummyResetVariable, true);
Set(DummyResetVariable, false);
Thanks Andrew, this is the approach i took in the end. All working now. Thanks for your assistance.
Good to hear, thank you!
Hi Andrew,
default-value in manifest doesn't appear to load false when using the pcf watch
^^ updated. default-value is only support by model-driven and not canvasApp
Hi Andrew, i've followed your approach to implement the reset functionality but when i import my PCF into the canvas app the 'Reset' property isnt available to set. Have you any idea why this would be?
Thanks