Enabling / disabling Feature in custom action - wix

I have a small setup project that contains 2 features, both published by default (Level = 1). In certain situations in custom action, I want to unpublish (set Level = 4) one of the features. Custom actions written in C#. How can I do that?

There are restrictions on where you can that, see the docs for the Condition table and doing this before CostFinalize:
https://msdn.microsoft.com/en-us/library/aa368014(v=vs.85).aspx
so assuming you have that under control, and you're early in the install then use a Feature condition. You already have a Feature element with level 1 by the sound of it, so add a condition that sets it to 4 when a property is set to something. In your code just set the property, and the level will change at CostFinalize.
Example:
Feature Id="FeatureX" Title="Feature X" Level="1"
<Condition Level="4"> <![CDATA[PROPVALUE=5]]> </Condition>

Related

OroCommerce: Disable order edit by some conditions

Is it possible to disable order editing when some conditions (like order status is shipped, but may be smtl else) are met?
Or disable LineItems editing but allow to edit order info?
Tried to add this lines to my current active order workflow and got nothing:
entity_restrictions:
test:
attribute: entity
field: customer_notes
tried to add this to one of workflow steps but again nothig
entity_acl:
update: false
delete: false
entity_restrictions and entity_acl are not used in any workflow.yml of oro bundles so is that functionality really implemented?
From the built-in features, you can use the workflow engine with the entity restrictions to make some form fields read-only based on conditions: https://doc.oroinc.com/backend/entities-data-management/workflows/configuration-reference/#entity-restrictions-configuration
Or create an access rule to hide the editing button and return 403 code for the editing page when conditions are met: https://doc.oroinc.com/backend/security/access-rules/#backend-security-bundle-access-rules
While I didnt found how to disable order edit via workflow like is was suggested previously here is the working way how to disable that via action configuration:
#MyBundle/Resources/config/oro/actions.yml
operations:
my_oro_order_edit
extends: UPDATE # this is for keeping all other properties same as in default
substitute_operation: UPDATE # replace UPDATE operation with current one
entities: ['Oro\Bundle\OrderBundle\Entity\Order'] # replacement will occur only if this operation will be matched by entity
for_all_entities: false
replace:
- preconditions
preconditions:
'#equal': [$internalStatus.id, 'open']
This substitutes UPDATE operation for order with my_oro_order_edit where conditions to allow UPDATE are changed - so edit button in order view page and orders grid will appear only for 'Open' orders. However this affects only buttons and its still possible to open order edit via direct link which should be prohibited using access rules

How can I have a Modify/Change install run the XmlConfig action to accept new values (values from public properties)?

I have XmlConfig entries such as this:
<util:XmlConfig Id='SetSomething'
File="[WEBSITE]Web.config"
Action='create'
Node='value'
ElementPath="//configuration/appSettings/add[\[]#key='something'[\]]/#value"
Value="[SOMETHING]"
On='install'
PreserveModifiedDate='no'
VerifyPath="//configuration/appSettings/add[\[]#key='something'[\]]/#value"
/>
Which works fine on Install. However for Modify/Change installs, I prefer to allow the same UI dialog sequence so that they can change the values. 'change' without having to uninstall/reinstall.
Is it supposed to work this way - maybe by how it is scheduled? And if so, is it possible to change that? So far it looks like all of my properties are published in time during a Modify/Change, however the SchedXmlConfig action is confusingly different looking in the logs in a Modify/Change than in an Install

WiX default REFERENCED value OR Registry Value

I need to set a default database file for my application. I only want it to be set on initial installation. If the registry value--a string of the path to the sdf file--changes, then future upgrades should not try to set the value back to the default.
Another caveat, that seems to be a problem, though, is that if they've never setup a database file, the user should be able to use the program with a default database without having to go through setup.
So I set the DATABASEFILE with value="[INSTALLFOLDER]dust.sdf". but candle was complaining that [INSTALLFOLDER]:
The 'DATABASEFILE' Property contains '[INSTALLFOLDER]' in its value which is an illegal reference to another property. If this value is a string literal, not a property reference, please ignore this warning. To set a property with the value of another property, use a CustomAction with Property and Value attributes.
So, following the error's instructions, I added a custom action. Now that custom action ALWAYS overwrites the DATABASEFILE attribute. I want it to only override that value if the value doesn't exist in the registry.
Here's the code:
<CustomAction Id='SetINSTALLFOLDERREF' Property='DATABASEFILE' Value='[INSTALLFOLDER]dust.sdf' Execute='immediate' />
<Property Id='DATABASEFILE' >
<RegistrySearch Id='DatabaseFile' Type='raw' Root='HKCU' Key='Software\DBG\Dust\Database' Name='File'/>
</Property>
Have you set conditions on your custom action with Id=SetINSTALLFOLDERREF? If not, you might want to do it.
A condition of NOT DATABASEFILE on your custom action should probably suffice.
With the above condition,
-In the case of a fresh installation, the registry entry does not exist. Hence, DATABASEFILE is NULL, the custom action condition evaluates to true and the custom action SetINSTALLFOLDERREF executes.
-For any subsequent maintenance operations, the registry key is present, the property DATABASEFILE will always contain a value, the custom action condition evaluates to FALSE and the custom action will not be triggered.
Another thing you might want to do is to add the property DATABASEFILE to the list of SecureCustomProperties ie. secure the property DATABASEFILE.

Using Rally.ui.AddNew with details

I've created a Rally.ui.AddNew button to add a new release.
If the user hits "Add with Details" (which is the only active button for releases, you can't add a release without details) I would like certain fields to be set by default when the dialog is opened.
For example, I would like the "Create matching Releases in all child projects" checkbox to be set (if it exists), and I'd like to put a default note in the "Notes" area.
How do I do that? It does not look like the listeners "beforecreate" or "create" are called if the details dialog comes up.
Ideally I'd also like a chance to check these items again with another listener just before the item is created. Do these listeners exist?
The Rally standard editor likely provides only limited capabilities for defaulting field values when instantiated. As an indication, AppSDK1 had the rally.sdk.util.Navigation.popupCreatePage() method, which would accept an object with default values, for example:
// Open Defect editor with Defect default-associated to User Story with OID 12345
rally.sdk.util.Navigation.popupCreatePage("defect", {requirementOid: 12345});
The default key/value pairs that this method accepts were not well-documented. One of Rally's UI Engineers provided me with this list at one time:
rally.sdk.util.Navigation.popupCreatePage defaults keys
User Story:
defaultName
rank
iteration
release
parent
dpyOid {dependency}
Defect:
defaultName
defectSuiteOid {Defect Suites}
testCaseResult
testCase
requirement
iteration
Defect Suite:
defaultName
rank
iteration
Portfolio Item:
defaultName
rank
parent
Task:
workProduct
Test Case:
testfolderOid {Test Folder}
artifactOid {Artifact}
Test Set:
iteration
release
While the above list may not be exhaustive (or even completely accurate anymore), it suggests that the allowed defaults for the standard Rally Editor may not include the "Create matching Releases in all child projects" checkbox or the Notes field.
Nonetheless, it's not immediately apparent to me that there is any method or config for AppSDK2's Rally.ui.AddNew that is an analog in functionality to AppSDK1's rally.sdk.util.Navigation.popupCreatePage() ability to setup default values into the resulting Editor window. Hopefully one of Rally's UI Engineers may have better information to add to this question.
Unfortunately for now not all the built-in fields are defaultable (see Mark W's answer above for the list of pre-fillable fields). Any custom fields are though. You'll want to check out the beforeeditorshow event. You can modify the params there.
addNewComponent.on('beforeeditorshow', function(addNew, params) {
params.defaultName = 'foo';
params.c_MyField = 'bar';
});
Note that if you would just like to create or edit objects you can directly call the methods on Rally.nav.Manager.

Conditions within custom actions

I recently separated our company installers in to two features (one enabled and one absent), to allow the user to select both, I've used UI_Mondo GUI to allow selection.
I've managed to get our custom action to work if the feature is selected:
<Custom Action="RestartIISForASPNet4" After="AspnetRegIIS"><![CDATA[(NOT INSTALLED) AND (&WebServiceFeature=3) AND NOT (!WebServiceFeature=3)]]></Custom
I tried but for some reason it's coming up with false (IMO, it can't as in the log the WixUI_InstallMode is set to InstallComplete.
<Custom Action="RestartIISForASPNet4" After="AspnetRegIIS"><![CDATA[((NOT INSTALLED) AND (&WebServiceFeature=3) AND NOT (!WebServiceFeature=3)) OR WixUI_InstallMode = "InstallComplete"]]></Custom>
Anybody have any ideas what I'm missing, it's probably really obvious.
WixUI_InstallMode is a private property. This means it uses its default value during InstallExecuteSequence (when your custom action runs).
A solution is to use custom action to save its value in a public property. You can then use that public property in your condition.
Public properties don't have lowercase letters in their names.