Hide/Disable Action Parameters?

Nov 10, 2011 at 5:40 PM

Is it possible to hide/disable action parameters that have their value automatically set by the framework by way of being called from the action menu of the domain object?

I.e.

I have a domain type called Customer.

I have an action as below:

public User AddUser(Customer customer, string firstName, string lastName)
{
  var user = this.Container.NewTransientInstance<User>();
  user.FirstName = firstName;
  user.LastName = lastName;
  user.Customer = customer;
  return user;
}

The "Add User" action will appear in the action menu whenever I am viewing a Customer.
When I execute the action, I don't want the Customer parameter to be editable in the action form dialog.

Is this possible?

 

 

Coordinator
Nov 10, 2011 at 5:55 PM
Edited Nov 10, 2011 at 5:56 PM

I am assuming that your AddUser method is implemented on a service (e.g. UserService), and is thus a 'contributed action' that appears on the Customer's action menu?

If so, then the answer to your question is 'no'  - unless you want to resort to customising the view of that action.

That said, it is not obvious to me why this should be implemented as a contributed action?  Normally, you would do this because you wanted the action contributed to several different types of object, in which case your signature might be:

 

where Customer implemented IHasUsers.

If you're not doing this, then why not put the action, with just the two params you want, on the Customer objects and then delegate execution to the method e.g.

public class Customer {
  public UserService UserService {set; protected get;} //Injected
 public User AddUser(string firstName, string lastName) {
    return UserService.AddUser(this, firstName, lastName);
  }
}

Note that to avoid having the service action being contributed (which would result in two similar actions on Customer) you can either register the UserService under SystemServices, or if that doesn't work, mark it as [NotContributedAction].

public User AddUser(IHasUsers context, string firstName, string lastName)
Nov 11, 2011 at 3:59 PM

Thanks for confirming this.