I'm trying to pre populate a customfeild with an employee that has the approver role.
I need to be able to add or remove users from the approver customfeild directly in the customer portal.
The choices will then be affectuated with the postfunction to add or remove the users from the system approver asset object.
But when i run this the approver will not populate the portal field, i have tried several diffrent takes on the aql.
Any ideas?
Assuming that customfield_11300 is another insight objects custom field, you then want to compare that against the Key attribute
object HAVING inR(objectType=Systems and Key=${customerield_11300}, reftype in ("Approver"))
If that doesn't work, try the following:
object HAVING inR(objectType=Systems and Key in(${customerield_11300${0}}), reftype in ("Approver"))
Yes, CF11300 is configured to show the systems available and cf11301 can present the choosen approvers
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Key refers to the Key attribute (created by default for all object types along with Name, Created, and Updated).
Issues only store the key of your object as a reference to the object.
IQL placeholder, the value of an insight custom field returned by ${customfield_xxxx} will be the key of the selected object. So if you want to find objects linked directly to the selected object, you need to match use the key of the selected object.
You should be able to use the IQL Search page to confirm this works:
Combine the filter scope IQL and filter assign scope IQL as:
objecttype=Userad and object having inR(Key=<enter a key for a selected system>, reftype in ("Approver"))
If you are getting the expected approver, then the auto-assign should work.
Be sure you delete the default/automatic value both in the custom field config and in the request type.
You'll also want to hide that field from the portal. The insight assign function is run via listeners, it doesn't show live on screen.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Peter
I figured that i was beggin for a miracle.
But i still wonder why the automatic choice in the cf is for backend use only?
Why would you use that? You can easy do the same with postf.
I can see a whole lot of usecases were a live cf update would be lifesaver.
Do you have any ideas how i can get the same results within the potal?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Jira and JSM are historically very simple in terms of front-end UI dynamic behavior (e.g. showing/hiding fields on the fly based selections or conditionally populating certain fields with different values other than the global default)
I use Scriptrunner Behaviour for that sort of thing.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yeah i'm starting to see that problem.
Sounds interesting, do you have any examples how you do it?
I have not used scriptrunner that much, but if you think there is a way to solve it i wanna aleast try.
I cant leave this matter unsoleved with this automatic but really nonautomatic feature.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Here is a sample script (untested) that would work in scriptrunner behaviour to apply a default value to 1 insight field based on selection on another.
You apply this script to the system field so that it runs each time that field is updated.
import com.onresolve.jira.groovy.user.FieldBehaviours
import com.onresolve.scriptrunner.runner.customisers.PluginModule
import com.onresolve.scriptrunner.runner.customisers.WithPlugin
import com.riadalabs.jira.plugins.insight.channel.external.api.facade.IQLFacade
import groovy.transform.BaseScript
@BaseScript FieldBehaviours fieldBehaviours
@WithPlugin('com.riadalabs.jira.plugins.insight') insightPlugin
@PluginModule IQLFacade iqlFacade
if (underlyingIssue) return //don't run after initial creation or else it would overwrite a selected approver
def systemField = getFieldById('customfield_11300')
def approversField = getFieldById('customfield_11301')
def selectedSystem = systemField.value
if (!selectedSystem) return //no selection was made, or the selection was clear, nothing more to do
if (selectedSystem instanceof List) {
//default to the first one if we have a list, generally, it's likely to be a list of size 1 anyway
selectedSystem = selectedSystem[0]
}
def iql = /objectType=Users and object having inR(objecType =Systems and Key = $selectedSystem, refType = "Approver")/
def approverObjects = iqlFacade.findObjects(iql.toString())
if (!approverObjects) {
approversField.setHelpText("No default approvers found for System $selectedSystem")
return
}
approversField.clearHelpText().setFormValue(approverObjects.first().objectKey)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Peter Thanx for the quick followup.
I couldnt get the Key variable to work it didnt return any value, what does key value do compared to Name or label?
I tried this one but with no luck, still nothing pre populated. only if i add the choosen value as default will it show up on the customfeild in the portal.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.