powerplatform-build-tools icon indicating copy to clipboard operation
powerplatform-build-tools copied to clipboard

Yes/No Boolean datatype Environment Variables do not update from settings file.

Open StylezDevops opened this issue 2 years ago • 2 comments

I have tested this with different values using the latest version of pac cli.

I have a single test solution. Within this solution I have an Environment Variable with the Boolean data type "Yes/No" - this value is set at the default: no

There is only a default value. I can see in the envrionmentvariabledefinition entity, in the defaultValue field that the value is either yes or no - in lowecase and appears to be just text.

When importing the solution with pac cli and the --settings-file option I am unable to set the value for this type of Environment Variable.

I have tried:

{
  "EnvironmentVariables": [
    {
      "SchemaName": "kd_danstylesboolean",
      "Value": "yes"
    }
  ],
  "ConnectionReferences": []
}

I tried:

{
  "EnvironmentVariables": [
    {
      "SchemaName": "kd_danstylesboolean",
      "Value": "Yes"
    }
  ],
  "ConnectionReferences": []
}

I also tried:

{
  "EnvironmentVariables": [
    {
      "SchemaName": "kd_danstylesboolean",
      "Value": 1
    }
  ],
  "ConnectionReferences": []
}

I even tried:

{
  "EnvironmentVariables": [
    {
      "SchemaName": "kd_danstylesboolean",
      "Value": true
    }
  ],
  "ConnectionReferences": []
}

I also tried the negatives of the above (No, false, 0, etc) and was unable to set the value of one of these Environment Variable types.

Thanks a lot and kind regards. DS

StylezDevops avatar Aug 17 '23 15:08 StylezDevops

Hello - Have you looked at this link: https://learn.microsoft.com/en-us/power-platform/alm/conn-ref-env-variables-build-tools

Please double check your environment variables in 'Default' solution and your new solution.

snizar007 avatar Aug 17 '23 21:08 snizar007

Thanks - I have looked at the link many, many, many times. The image below is prior to setting value with pac cli and a settings file. See image below. image

Here is the settings file: image

Here i run the command: image

Here we see the solution has imported: image

I dont even NEED to look in the default solution - I can view the contents of this record from powershell: image

We can see the default value has NOT been set. there is not a current value. For further verification i will now screenshot the variable in the default solution: image

The value, as specified in the settings file.. has NOT been set.

However, if I do it like this:

> $EV = Get-CrmRecord -conn $conn -EntityLogicalName environmentvariabledefinition -Id $recID -Fields schemaname,defaultvalue
> $EV

defaultvalue_Property                    : [defaultvalue, no]
environmentvariabledefinitionid          : c82cf57b-7058-4cd3-b7c3-a57949ac6b0e
logicalname                              : environmentvariabledefinition
schemaname_Property                      : [schemaname, kd_danstylesboolean]
original                                 : {[schemaname_Property, [schemaname, kd_danstylesboolean]], [schemaname, kd_danstylesboolean], [defaultvalue_Property,   [defaultvalue, no]], [defaultvalue, no]...}
ReturnProperty_EntityName                : environmentvariabledefinition
EntityReference                          : Microsoft.Xrm.Sdk.EntityReference
ReturnProperty_Id                        : c82cf57b-7058-4cd3-b7c3-a57949ac6b0e
environmentvariabledefinitionid_Property : [environmentvariabledefinitionid, c82cf57b-7058-4cd3-b7c3-a57949ac6b0e]
defaultvalue                             : no
schemaname                               : kd_danstylesboolean

> $EV.defaultvalue="yes"
> $EV


defaultvalue_Property                    : [defaultvalue, no]
environmentvariabledefinitionid          : c82cf57b-7058-4cd3-b7c3-a57949ac6b0e
logicalname                              : environmentvariabledefinition
schemaname_Property                      : [schemaname, kd_danstylesboolean]
original                                 : {[schemaname_Property, [schemaname, kd_danstylesboolean]], [schemaname, kd_danstylesboolean], [defaultvalue_Property,       
                                           [defaultvalue, no]], [defaultvalue, no]...}
ReturnProperty_EntityName                : environmentvariabledefinition
EntityReference                          : Microsoft.Xrm.Sdk.EntityReference
ReturnProperty_Id                        : c82cf57b-7058-4cd3-b7c3-a57949ac6b0e
environmentvariabledefinitionid_Property : [environmentvariabledefinitionid, c82cf57b-7058-4cd3-b7c3-a57949ac6b0e]
defaultvalue                             : yes
schemaname                               : kd_danstylesboolean

> Set-CrmRecord -CrmRecord $EV
>$EV = Get-CrmRecord -conn $conn -EntityLogicalName environmentvariabledefinition -Id $recID -Fields schemaname,defaultvalue
>$EV

defaultvalue_Property                    : [defaultvalue, yes]
environmentvariabledefinitionid          : c82cf57b-7058-4cd3-b7c3-a57949ac6b0e
logicalname                              : environmentvariabledefinition
schemaname_Property                      : [schemaname, kd_danstylesboolean]
original                                 : {[schemaname_Property, [schemaname, kd_danstylesboolean]], [schemaname, kd_danstylesboolean], [defaultvalue_Property, [defaultvalue, yes]], [defaultvalue, yes]...}
ReturnProperty_EntityName                : environmentvariabledefinition
EntityReference                          : Microsoft.Xrm.Sdk.EntityReference
ReturnProperty_Id                        : c82cf57b-7058-4cd3-b7c3-a57949ac6b0e
environmentvariabledefinitionid_Property : [environmentvariabledefinitionid, c82cf57b-7058-4cd3-b7c3-a57949ac6b0e]
defaultvalue                             : yes
schemaname                               : kd_danstylesboolean

We see it change AND I can now see the value reflected in the default solution. image

I trust this is now enough information to log this as a bug. this is not a case of user error and i have quite thoroughly investigated it. Kind Regards DS

StylezDevops avatar Aug 18 '23 08:08 StylezDevops