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.

Reply
  • 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.

Children
  • 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
    

  • Not only that it compiles in v92: It works too!!

    Thanks Markus!! 

  • I'm having a similar requirement where I need to configure a request property in a way that a user-promt parameter is only visible for users that are member of a specific AERole.

    i tried the following script in both valuation and data dependencies script but it did not work. 
    Error on webserver: "---> VI.Base.ViException: Der Wert UID_PersonInserted wurde nicht gefunden."


    Can you tell me how I can achieve my requirement?

    Dim f As ISqlFormatter = Session.SqlFormatter()
    
    Dim dbEntity As IEntity = Session.Source.Get(ParameterSet.UsedBy, EntityLoadType.ReadOnly)
    Dim uidPersonOrdering = dbEntity.GetValue(Of String)(Table.ShoppingCartItem.UID_PersonInserted)
    Dim uidAERole As String = "someUID"
    
    If Session.Source.Exists(Table.PersonInAERole, f.AndRelation( _
    	f.UidComparison(Table.PersonInAERole.UID_AERole, uidAERole), _
    	f.UidComparison(Table.PersonInAERole.UID_Person, uidPersonOrdering))) Then
    	
    	ParameterSet("param1").IsVisibleForChildren = True
    	ParameterSet("param1").IsReadOnly = False
    	ParameterSet("param1").IsMandatory = True
    	
    Else 
    	ParameterSet("param1").IsVisibleForChildren = False
    	ParameterSet("param1").IsReadOnly = True
    	ParameterSet("param1").IsMandatory = False
    	
    End If