Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Sometimes it is necessary For new options how to disable the Submit Quote button in Quote Configurator. There are two ways to do this.

One way is to throw an exception, which automatically disables the Submit Quote button. This must be done in the quote header logic post-phase.

This is usually done only for some users. Rather than assigning this functionality to various groups (such as Sales, Marketing, Pricing, etc.) I find it much easier to create a single group called “Block Submit” and then add the users to that group as necessary – regardless of the other groups they may belong to. This way there is no need to touch the code every time the client decides that another group should have the Submit Quote button disabled for them.

Code Block
def ug = api.find("U", Filter.equal("groups.uniqueName", "Block Submit"))

def loginName = api.user().loginName

if (quoteProcessor.isPostPhase() && api.isUserInGroup("Block Submit", loginName) == true) {
  api.throwException("This user does not have permission to submit quote")
}

Note: The exception MUST be thrown in PostPhase. Otherwise it won't work.

This way has a couple of drawbacks. When this functionality is triggered the QC displays a generic error message “Quote calculated with errors”, which may confuse the user. Also, if another exception is thrown it’s not as obvious to the user because an error is expected. But more importantly throwing an exception may interfere with other functionality in the quote – such as Meta Configurator.

Another – and possibly a better – way to disable the Submit Quote button is to create a HIDDEN input with a required value and assign null to the value. Like so:

Code Block
quoteProcessor.addOrUpdateInput(
	"ROOT",
	["name": "submitQuoteEnable",
     "label": "Enable Submit Quote",
     "type": InputType.HIDDEN,
     "required": true,
     "value": null
    ])

This does not throw an exception – but disables the Submit Quote button. For users who should be able to submit the quote simply assign some non-null value. A simple string will do.

Code Block
quoteProcessor.addOrUpdateInput(
	"ROOT",
	["name": "submitQuoteEnable",
     "label": "Enable Submit Quote",
     "type": InputType.HIDDEN,
     "required": true,
     "value": "Yes"
    ])

The full code looks like this:

Code Block
linenumberstrue
def groups = api.user().allGroups
def groupList = []

for (group in groups) {
  groupList.add(group.uniqueName)
}

  if (groupList.contains("Block Submit")) {
    quoteProcessor.addOrUpdateInput(
	"ROOT",
	["name": "submitQuoteEnable",
     "label": "Enable Submit Quote",
     "type": InputType.HIDDEN,
     "required": true,
     "value": null
    ])
  }else{
    quoteProcessor.addOrUpdateInput(
	"ROOT",
	["name": "submitQuoteEnable",
     "label": "Enable Submit Quote",
     "type": InputType.HIDDEN,
     "required": true,
     "value": "Yes"
    ])
  }

...

, see How to Hide, Disable or Make Required Fields/Buttons