Make cascading list mandatory on JIRA based on another cascading list - jira

I think this can be achieved with behaviors but I am struggling with the code.
I am trying to make "Cascading list 2" mandatory when an option is picked from "Cascading list 1"
Eg:
On "Cascading list 1" if a user picks option "A" then they have to also fill out "Cascading list 2"
If they pick option "B" on "Cascading list 1" then "Cascading list 2" is not required.
This is some of the code I was playing around with:
def fieldA = getFieldByName('BI Reporting & Analytics Request Categories') //this is cascading list 1
def fieldC = getFieldByName('Reporting') //this is the cascading list 2
def fieldAValuesThatTriggerFieldCRequired = ['Reporting'] //this is the option choosen in cascading list 1
def valueA = fieldA.value
def fieldCIsRequired = valueA in fieldAValuesThatTriggerFieldCRequired
fieldC.setRequired(fieldCIsRequired)
Any assistance is appreciated.
Image on JIRA
Thanks.

If my understanding is correct, they are not cascading field.
The request here is that when field A has particular value saying 'aaa', then field B becomes required (mandatory).
This is a typical use case for Jira plugin Adaptavist ScriptRunner behaviours.
But Behaviours is only available for Jira server or data center version. It is not for Jira cloud.
If your Jira is server version, you can refer to below steps and scripts:
go to behaviours settings, if you don't have a behaviour item for
your workflow, please create it. If behaviour has been created,
click into action/edit.
choose the field A and add it.
click Add server-side script, you will see the black inline edit section.
add below code.
import com.onresolve.jira.groovy.user.FieldBehaviours
import com.onresolve.jira.groovy.user.FormField
import groovy.transform.BaseScript
#BaseScript FieldBehaviours fieldBehaviours
FormField field1 = getFieldById(getFieldChanged()) // we need to capture the change in field 1.
FormField pmAuthor = getFieldByName("field2")
if (field1.getValue()) { // to check if field1 has value as the action on field could be a deleting value operation.
if (field2.getValue()=="A") {
field2.setRequired(true)
} else {
field2.setRequired(false)
}
} else { // if the value was deleted, then remove the requirement.
field2.setRequired(false)
}

Related

How to examine and change actions on commercetools updateCart query?

My question is this:
Is there a feature or method within graphql that allows editing of incoming queries EASILY so that I can prevent an action from being performed? I would like to examine my query in a web proxy, edit the actions, and then send it on to its destination.
Context:
I have a mutation running in a proxy service for commercetools that looks like this:
mutation AddLineItem(
$id: String
$version: Long!
$sku: String
$quantity: Long
$currencyCode: Currency!
$centAmount: Long!
$custom: String!
) {
updateCart(
version: $version
id: $id
actions: [
{
addLineItem: {
sku: $sku
quantity: $quantity
externalPrice: { centPrecision: { currencyCode: $currencyCode, centAmount: $centAmount } }
custom: { typeKey: "custom-type", fields: [{ name: "field", value: $custom }] }
}
}
]
) {
id
version
lineItems {
...LineItemFieldsCart
}
}
}
According to the commercetools documentation, when the external price field is set, duplicate items will be added as separate line items to the cart instead of increasing the quantity, as is the default behavior. The thing is, I want the default behavior instead of the duplicate line items. The normal way to mitigate this is to add an update extension to delete the duplicates, but I am working on an already mature system that has multiple update extensions that all operate on the line items, making a delete apparatus a heavy lift in the update extension. I want to edit the query in the proxy so the duplicate item never happens in the first place. Is there an easy way to do this?
for the add line item update action the current behaviour is to create a separate line item when external prices are used and not add the additional quantity to the already existing line item as you described.
If you want to make sure that the quantity is added to the already existing line item when using external prices, you could do a check prior to adding a new line item and use the update action change line item quantity in case the product variants match with the line items that already exist in the cart. This will let you set the external price there and will not add any additional like items. https://docs.commercetools.com/api/projects/carts#change-lineitem-quantity

How do I make dropdown roles in pycord?

As many may know, discord.py has stopped being maintained. As a result of this, I switched over to Pycord.
My question is:
How do I make the dropdown menu do roles?
I looked at the example on the Github Example file for making dropdown menus in Pycord, and I attempted to make a dropdown menu (successfully). However, this only sends a message when an option is selected from the menu. I want to use this menu for adding and removing roles. How would I go about doing that?
class Select(discord.ui.Select):
def __init__(self):
options = [
discord.SelectOption(label="role name", description="Add the Role_Name role"), #These are the labels
discord.SelectOption(label="role name 2", description="Add role name role."),#^
]
super().__init__(placeholder="Waiting for selection...", max_values=1, min_values=1, options=options)#what will be written waiting for a choise
async def callback(self, interaction: discord.Interaction):
if self.values[0] == 'role name': #'role name'must be the same as the label u want the action to happen. Ex: if label name == hi, well uchange role name to hi here
role = interaction.guild.get_role(ROLE_ID_HERE)#add ur role ID here
await interaction.user.add_roles(role)#Basically if the interaction happen, itll add the role role^ to the user
elif self.values[0] == 'role name 2':
rolee = interaction.guild.get_role(ROLE_ID_HERE)#same as up
await interaction.user.add_roles(rolee)
class SelectView(discord.ui.View):
def __init__(self, *, timeout):
super().__init__(timeout=timeout)
self.add_item(Select())
#client.command()
async def droproles(ctx):
select = SelectView(timeout=None)
await ctx.send("Choose ur role here", view=select)
This is the code. If there is an error tell me, i didnt test it, but it should work. If u dont understand something, tell me. U need to understand to be able to re do it sometime

Queries related to JIRA-Scripted Field

Is scripted field appear on ISSUE EDIT or any transition screen?
For me, it appear on issue view screen only and unable to see on issue edit screen.
I want it to appear on EDIT screen as well as a readonly.
(have verified by just keeping - "free text template" and - return "some value").
Another:
When I have use below script on scripted field then it shows me error while execute:
Error message as below:
The indexer for this field expects a java.lang.String but
the script returned a com.atlassian.jira.issue.fields.CustomFieldImpl - this will cause problems.
Code:
import com.atlassian.jira.ComponentManager.
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.CustomFieldManager
CustomFieldManager customFieldManager = componentManager.getCustomFieldManager()
def componentManager = ComponentManager.getInstance()
def issueLinkManager = componentManager.getIssueLinkManager()
def selectedValues = customFieldManager.getCustomFieldObject("customfield_11447")
//custom field has multi selected values as it is a "multi select" field type.
return selectedValues
How I could use scripted field in issue edit/transition screen and also resolve above error.
For the first part of your question, no a scripted field wont be displayed on a Create, Edit or Transition screen. There is a work around for transition screens but I have not tried it https://gist.github.com/jechlin/5380119
Now the second part of your question. You are returning an object of CustomeField and you should be returning a String. What you want to do is
change this
def selectedValues = customFieldManager.getCustomFieldObject("customfield_11447")
to this
def cf = customFieldManager.getCustomFieldObject("customfield_11447")
def selectedValues = cf.getValue(issue)
Here is a link to the api documentation for JIRA (6.0.4):
https://developer.atlassian.com/static/javadoc/jira/6.0.4/reference/packages.html

How to get Customized template fields from invoice using QuickBooks QBFC

I want to get custom S.O. Invoice Template fields using QuickBooks QBFC.
Here's how to read custom fields from a sales order:
Add "0" to the OwnerIDList of the SalesOrderQuery.
Read custom header fields from the DataExtRetList that is attached to SalesOrderRet objects that are returned from the query.
Read custom line item fields from the DataExtRetList in the SalesOrderLineRet and SalesOrderLineGrouptRet objects that are included in each SalesOrderRet (if you're reading line items).
If you're already using the IncludeRetElementList, you must add DataExtRet to the list; if you're not then don't start using IncludeRetElementList until you have custom fields working. Just like any transaction query, you won't see any line item data unless you set the IncludeLineItems flag in the request.
Custom fields are well documented in the QuickBooks SDK Manual. I'd recommend you take a look at the section DataExt: Using Custom Fields and Private Data in the QBSDK Programmers Guide.
To elaborate on Paul Keister's answer, the reason you must add "0" to the query is because that is the Owner ID of the custom field you are attempting to retrieve. 0 is probably likely to be the value, but if the owner ID is different, you will have to use a different value here.
Some example C# code:
//set the owner id of the custom field you are trying to get back
IInvoiceQuery invoiceQuery = requestMsgSet.AppendInvoiceQueryRq();
invoiceQuery.OwnerIDList.Add("0");
//set up query parameters and actually call your query...
//call this method for each invoice to get its custom fields (if they exist)
static void GetInvoiceCustomFields(IInvoiceRet invoice)
{
if (invoice.DataExtRetList == null)
{
return;
}
for (int i = 0; i < invoice.DataExtRetList.Count; i++)
{
IDataExtRet extData = invoice.DataExtRetList.GetAt(i);
Console.WriteLine("external data name: " + extData.DataExtName.GetValue());
Console.WriteLine("external data value: " + extData.DataExtValue.GetValue());
}
}

SPListItem.Update and SPFile.Update fail

We are running one MOSS application as below:-
1. user use InfoPath request form to trigger workflow attached to SharePoint document library
2. all sub-sequent tasks are performed by users by InfoPath task form within SharePoint site through "Workflow Task" list (open, checkout, approve or reject) till the task completed.
3. all request form submitted could be viewed as xml file in the document library through "Explorer View"
My quesiton is why I cannot update the item located in the document library, basically open the SPListItem:-
SPSite thisSite = new SPSite("http://server")
{
SPWeb thisWeb = thisSite.OpenWeb("/web")
{
thisSite.AllowUnsafeUpdates = true;
thisWeb.AllowUnsafeUpdates = true;
SPDocumentLibrary library = (SPDocumentLibrary)thisWeb.Lists["DocLib"];
foreach (SPListItem item in library.Items)
{
SPFile file = item.File;
I tried almost all ways I could find:-
item["Customer Name"] = "123456";
item.Update();
// or item.SystemUpdate();
file.Item["Customer Name"] = "123456";
file.Update();
After each update, the value resumed when reopen or visit through the same code lines!
but when I view item properties, the "Last modified" is changed
Last modified at 6/8/2010 12:27 AM by Administrator
This do drive me cray, any help, please.
Thanks & best regards,
Leon
When you publish your form to a list, it asks you to choose the fields to be shown on that list. As you choose the item you want to update, click "Modify". Check the checkbox
at the bottom saying "Allow user to edit data in this field by using a datasheet or property page". This works for me.

Resources