Request properties (new style): Change parameter type dynamically

Hi,

In v92 I have a request property with a "User prompt" parameter that shows a selectable list of organizations the recipient belongs to when requesting a specific product.

A change has been approved that this selection should be skipped if the recipient belongs to only one organization. So I'm using the OnPropertyChangedScript to get a list of organizations for the recipient and try to  set the parameter to "Calculated" should this list had only one element. 

Problems I need help on:

  1. I'm unable to get the UID_PersonOrdered in the script. I've been browsing the forums and found this Provider.GetValue(Of string)("UID_PersonOrdered") object (not in the documentation) but that is not returning any value at all.
  2. I don't know how to set the parameter to "Calculated". I know how to set it to readonly (ParameterSet("param").IsReadonly) or mandatory, but I cannot find how to alter the ParameterType.
  3. Juan Carlos, forget it, that's not the way at all.

Any ideas?
Thanks.

Parents
  • Regarding number 2, I think that you cannot change the parameter type to Query in the script.  But should be able to set the value of the parameter in the script with ParameterSet("ParameterName").Value = <Your Value> and setting the parameter to ReadOnly and make it optional with ParameterSet("ParameterName").IsReadOnly = True and ParameterSet("ParameterName").IsMandatory = False

    Regarding number 1, I need to dig into this thoroughly about how to access the property.

  • I do not know if the following is working in 9.2 as well but it works in 9.3. But remember that the code is not just called when the parameter value has changed but during the initialization of the property as well.

    ' You need to check if your code is running for the parameterset assigned to the AccProductParamCategory (the parent parameterset)
    ' or for the parameterset assigned to your ShoppingCartItem.
    If ParameterSet.UsedBy.TableName = "ShoppingCartItem" Then
    	' Get the entity the parameterSet is assigned to
    	Dim dbEntity As IEntity = Session.Source.Get(ParameterSet.UsedBy, EntityLoadType.ReadOnly)
    	
    	Dim uidPersonOrdered = dbEntity.GetValue(Of String)(Table.ShoppingCartItem.UID_PersonOrdered)
    	' Do something with the uidPersonOrdered
    	Log.Info(String.Format("NON-INIT: UID_PersonOrdered = '{0}'.", uidPersonOrdered))    
    End If
    

Reply
  • I do not know if the following is working in 9.2 as well but it works in 9.3. But remember that the code is not just called when the parameter value has changed but during the initialization of the property as well.

    ' You need to check if your code is running for the parameterset assigned to the AccProductParamCategory (the parent parameterset)
    ' or for the parameterset assigned to your ShoppingCartItem.
    If ParameterSet.UsedBy.TableName = "ShoppingCartItem" Then
    	' Get the entity the parameterSet is assigned to
    	Dim dbEntity As IEntity = Session.Source.Get(ParameterSet.UsedBy, EntityLoadType.ReadOnly)
    	
    	Dim uidPersonOrdered = dbEntity.GetValue(Of String)(Table.ShoppingCartItem.UID_PersonOrdered)
    	' Do something with the uidPersonOrdered
    	Log.Info(String.Format("NON-INIT: UID_PersonOrdered = '{0}'.", uidPersonOrdered))    
    End If
    

Children