Receiving a null return value from a custom action - dynamics-crm

In testing custom actions, we built one through the native process designer UI that assigns an arbitrary value to an output argument.
However, no matter what type of output argument we use, no matter the value of input or output, we always receive a null response for that output argument.

We had a step to stop the custom action with a status of "xucceeded" after the assign value step. Once that step was removed, everything worked fine.

Related

Power Automate: Run a child flow by GUID

I'm trying to call a child flow from a Power Automate flow by it's guid (by using an Expression in the Child Flow dropdown), instead of hardcoding the child flow selection.
However, whenever I try to save the parent flow, I get the following error:
Request to XRM API failed with error: 'Message: Flow client error returned with status code "BadRequest" and details "{"error":{"code":"ChildFlowIdNotValid","message":"The workflow id '[[expression]]' is not a valid child flow id. The id must be a valid GUID."}}". Code: 0x80060467
I tried various expression, even simple stuff like #guid() (which is definitely a valid guid), but to no avail.
It seems like the platform performs a "compile time" check on the value, which makes using any dynamic value impossible.
Any ideas?
I think that Run Child flow action is designed to be more interactive than programmable, unfortunately. Interacting with the Run Child Flow action calls an API, and the response is used to modify the action definition. Whatever is the "custom value" expression - it is not evaluated, but instead read as string, and used in a call to retrieve the sample header. That sample is then used to re-format the Run Child Flow action to show the appropriate headers.
Having an undetermined target would mean the call body is not defined, which could be a problem. Interestingly, it does pop a spot for a body when initially trying to look for a hard-coded GUID.
You can see the after-effect of this behavior in how even hardcoded GUIDs get replaced with the flow names once saved/reopened.
As a workaround, I stack Run Child flows in a Switch action checking an expression result. I.e.:
Switch workaround
Side note - GUID() in Azure Logic Apps (and powerautomate) does not format an arbitrary string as GUID.

Optional Input parameters in CRM action always NULL in Code Activity even if not passed?

If I ommit an optional input parameter in a CRM action call, will this parameter always be null in the Code Activity?
We have a customer which calls a particular CRM action, lets say an update action. The customer wants to be able to pass input parameters as null if the value in the corresponding field in dynamics must be deleted.
the problem i an facing now is that I cannot detect wether the input variable was effectively passed like "parameter_1 = null" or if the parameter itself was not even passed in the action call. the issue is that I cannot delete the value in crm if the input parameter was just not passed. only if the parameter was passed with the value null, I am allowed to delete the field value in crm.
Am I correct assuming that the value of a optional action input parameter is also null if the parameter is not passed at all?
Is there maybe a workaround which enables me to detect wether the value of the input parameter was passed as null instead of beeing ommitted?
something like "undefined" or similar?
You are correct. Input parameters are always present in the IPluginExecutionContext.InputParameters collection passed to the plugin handling your action.
You would need an extra "MyParameterNameSpecified" so to speak to signal if the parameter null value was actually passed.
Another option could be to use a string parameter holding the value passed in JSON-serialized form.

How do I handle null values during model binding

I have the folowing URL:
http://localhost:7975/test?parameter01=X
In my model, parameter01 is a List<int?>. If a non-integer value (e.g., a string) is passed to this parameter, the model binding process sets this value to null.
How do I intercept this as early as possible in the pipeline so I can return a HTTP status and description without handling this condition in the controller action?
Since you have tagged with asp.net-web-api2 I would recommend using Attribute Routing which enables you to constrain the Parameter Type. With this you'd able to switch handling according to the validity of your input. You can read up on this here
A second possibility would be to write a HTTPHandler which tests for valid input information. This one might be a bit trickier.

React validating whether one of the input fields are been entered

I have a scenario where I have to validate whether one of the input fields have values entered.
In the OnBlur Event of each input field I get the value and set in the state, and in the mean time I check whether there is values in one of those input boxes and set the inputIsReq state. And I use that inputIsReq in the required attribute in each text field. After this change my page loads really slow, and the validations doesn't happen too. Any idea to fix this ?
Your code is running slow because you are calling the method changeInputValue instead of passing it as a callback.
this will call changeInputValue:
wrong:
onBlur={this.changeInputValue("input_4_value", this)}
correct:
onBlur={() => this.changeInputValue("input_4_value", this)}
Abowe example will pass changeInputValue as a callback.
you can also
onBlur={changeInputValue} but then you can't pass any params to callback
You were calling changeInputValue in a loop since it have changed the state and then component was re rendered and so on... This was also producing the warning in a console
warning.js:36 Warning: setState(...): Cannot update during an existing
state transition (such as within render or another component's
constructor). Render methods should be a pure function of props and
state; constructor side-effects are an anti-pattern, but can be moved
to componentWillMount.

Get value of editbox of type date/time

I try to get the value of an editbox of type Date/Time. If I test it with
getComponent("dateField").value
or
getComponent("dateField").getSubmittedValue();
and print the output to the console. It always returns "null" if the field is empty or
the field does not contain a valide date. Because of this I can't differ between invalide input and empty input.
Is there a way to get the information if the field is empty?
It depends on the refresh phase you're testing.
getValue() will always return blank, because only content that can be converted to the underlying data type will be passed to it. Even if you disable validation, converter checks still run, because serious errors will occur if you try to put "this is not a date" into a Date/Time.
getSubmittedValue() will always be null if you're checking in Invoke Application or Render Response phases. That's because during the Update Model Values phase, the submittedValue property is passed to the value property and the submittedValue property nulled.
If you're checking in a validator, the text value entered by the user has not yet been checked against validation rules (validation) or that it can be converted to the right data type (conversion), so getValue() will return the value stored last time round and getSubmittedValue() will give the string value (e.g. "this is not a date").
So the answer is you should be able tell whether the field is empty in a validator, but bear in mind custom validators only run if you also have a required validator.

Resources