Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Customer Account to User Picker Custom Field on Customer Portal

Alvin
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Champions.
October 3, 2018

Hi Community, Is it possible to set default value in user picker custom field by the current user in customer portal? using behavior ?

Screenshot from 2018-10-03 11_29_58.pngI need to capture the current user on" Requested for " user picker custom field  like on the above "Raise this request on behalf of" system field.

 

I tried it using this behavior , place it on Initialiser, mapped to Service Desk Project, because I just want it to become a default value. but no luck, any chances? When I try to check the console in chrome (f12)

When user is admin account, it can capture the user and place on the field, but when the user is customer account, it returns this error

Screenshot from 2018-10-03 13_38_08.png

 Upon checking the behavior log , it returns this message:

2018-10-04 02:02:06,584 http-nio-8080-exec-8 DEBUG legoteam 122x13663x1 12ftncq 54.153.253.180,10.66.49.4 /rest/scriptrunner/behaviours/latest/jsd/jsd/validatorsByPid.json [c.o.j.groovy.user.FieldBehaviours] ------------------------TESTING BEHAVIOR-------------------------------

Upon checking /rest/scriptrunner/behaviours/latest/jsd/jsd/validatorsByPid.json, it returns this message:

"Cannot retrieve validators from PortalID: '{null}' , Request Type ID : '{null}'"

This is the code:

import com.onresolve.jira.groovy.user.FormField
import com.onresolve.jira.groovy.user.FieldBehaviours
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.component.ComponentAccessor

def requestorField = getFieldById("customfield_10385")

def currentUserName = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser().getName()
requestorField.setFormValue(currentUserName)

1 answer

1 accepted

Suggest an answer

Log in or Sign up to answer
0 votes
Answer accepted
Jonny Carter
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Champions.
July 14, 2020

Hey, @Evanthia Charalampidou ! We just published a script to the Adaptavist Library based on this exact use case.

https://library.adaptavist.com/entity/comment-on-jira-issue-for-linked-confluence-pages

The script presumes that you have ScriptRunner for Confluence and ScriptRunner for Jira, though you need only to configure the Event Listener in Confluence. The script is written for Jira 8.x and Confluence 7.1+, but could probably be tweaked for a lower version so long as you have the latest compatible version of ScriptRunner.

Mark Kindy
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
September 3, 2021

Hi @Jonny Carter -- is there a chance there is a similar use case for the Cloud version? 

Jonny Carter
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Champions.
September 20, 2021

@Mark Kindy- yup! Take a look at https://docs.adaptavist.com/sr4cc/latest/features/script-listeners . That details how to create a Jira ticket, not a comment, but you should be able to use the REST APIs to create a comment just as well.

TAGS
AUG Leaders

Atlassian Community Events