0 votes

the following script should create a ticket when an onboarding has been submitted in Adaxes:

Import-Module JiraPS       

$password = ConvertTo-SecureString "password"  -AsPlainText -Force
$credential = New-Object System.Management.Automation.PSCredential ('adaxes@domain.com', $password)

Set-JiraConfigServer 'https://domain.atlassian.net'
New-JiraSession -Credential $credential

#Format datetime
$dateConversionFormat = "yyyy-MM-dd"
$duedate_origin = $Context.TargetObject.Get("adm-CustomAttributeDate1")
$duedate = $duedate_origin.ToString($dateConversionFormat)

$initiator = Get-AdmUser  -Filter 'mail -like "%initiator%"'

Try{
    $issue = New-JiraIssue -Project "IOO" -IssueType Task -Summary "%param-summary%" -Description "%param-description%" -Labels "Onboarding" -Reporter $initiator.UserPrincipalName
    Set-JiraIssue -Issue $issue.Key -Fields @{ duedate = $duedate } 
    Set-AdmUser "%distinguishedName%" -Add @{"adm-CustomAttributeText20"=$issue.Key} -AdaxesService localhost
    $Context.LogMessage("Opening Jira Ticket $issue.Key with summary: %param-summary%", "Information")
}
Catch{
   $Context.LogException($_.Exception)
}
Finally{
    Remove-JiraSession
}

When running the onboarding process, the following errors appear:

Exception calling "Get" with "1" argument(s): "The 'adm-CustomAttributeDate1' property cannot be found in the cache." Stack trace: at <ScriptBlock>, <No file>: line 16
You cannot call a method on a null-valued expression. Stack trace: at <ScriptBlock>, <No file>: line 17
by (20 points)

1 Answer

0 votes
by (227k points)

Hello,

The error occurs because adm-CustomAttributeDate1 is empty for the user the script is run on. To avoid such issues, use try-catch blocks for retrieving property values. For example, if you use the below approach, the script will exit if the property is empty:

try
{
    $duedate_origin = $Context.TargetObject.Get("adm-CustomAttributeDate1")
}
catch
{
    $Context.LogMessage("Property adm-CustomAttributeDate1 is empty.", "Warning")
    return
}

Related questions

0 votes
0 answers

Hi, how can I change Help Desk to something a little more specific like "Onboarding Portal"? Or a bit more catchy that our HR will like rather then see Help Desk in the left hand corner.

asked Oct 9, 2019 by 6FigureMission (140 points)
0 votes
1 answer

We are looking to use Adaxes to create and manage Managed Service Accounts in the "Managed Service Accounts" OU. Is this possible through Adaxes? Thank you.

asked Nov 14, 2019 by lgibbens (320 points)
0 votes
1 answer

I want to remove special characters on the onboarding web form for username and mail before clicking Finish. Using a script like on the rule "Before User Creation" seems to to do the change to late and you can not verify the email adress before created.

asked Dec 27, 2021 by joem (20 points)
0 votes
0 answers

You do not need to create a trust between AD domains to manage them with an Adaxes service. When registering an AD domain, an account with administrative permissions ... control the user access to the managed resources, the Adaxes service uses Security Roles.

asked Apr 29, 2009 by Adaxes (380 points)
0 votes
1 answer

Automation of user creation based on ServiceNow ticket creation.

asked Jan 24 by tdetmer (20 points)
2,801 questions
2,535 answers
6,605 comments
61,659 users