fetch the issues from jira only when it has particular customfield using python - python-3.x

I am doing automation on Jira, now I want fetch the data from tickets, but the tickets must have the customfield_10030, otherwise the tickets should not be selected.
Below is the code, I am using, please help me out
from atlassian import Jira
jira_instance = Jira(
url = "https://xxxxxxx.atlassian.net/",
username = "username#gmail.com",
password = "API token",
)
data = jira_instance.jql("project = ProjectName AND status = 'Open' ORDER BY created ASC")
The above code fetches all the tickets in open status under the project. But I want to fetch all the tickets in open status and has the customfield_10030, only then it should be selected.
Please help me out in this

JQL:
customfield_10030 is not empty

The JQL would be: project = ProjectName AND status = 'Open' AND cf[10030] is not empty ORDER BY created ASC
It's best to refer to custom fields by their ID, not their name, in case someone changes the name or there are other fields with the same name.

Related

SuiteScript getting value from a saved search

I'm having an issue pulling the value of a column in SuiteScript v1.0. The search is looking at Cash Sales and is producing the results I want in the UI, but I am unable to get the value of one column in SuiteScript. I suspect it is because either the value comes from the 'Created From' doc, or because it is a drop down list. Any help would be greatly appreciated.
The search looks at Cash Sales where the Dept/Sales Channel (NS id department) doesn't match the Dept/Sales Channel of the Sales Order. The results are:
Type
Document Number
Created From : Dept/Sales Channel
In the UI, it is doing exactly what I hoped. However, when I loop thru the results in my v1.0 SuiteScript, I'm getting a null value for Dept/Sales Channel:
results.forEachResult(function(res){
var id = res.getId();
var docid = res.getValue('tranid');
var dept = res.getValue('channel');
nlapiLogExecution('DEBUG', 'Found result - '+docid+' ('+id+') - '+dept+'.');
docid and id are correct, but dept ends up being null. I've tried 'channel', 'deptartment' and column[3].value with no luck. What am I doing wrong?
Based on how you formatted this: "Created From : Dept/Sales Channel", I assume it is a joined column.
If it is, you need to do it this way:
var dept = res.getValue('department', "createdfrom");

Google Form Search and Pull Spreadsheet Data

Hi I have google spreadsheet that contains customers' ID and their shipping status. I want to create google form where customers are able to input each of their own ID, with the return that the google form shows their shipping status.
I tried to look for solutions in internet but there was no luck. I am not really good in programming, i hope there is answer to this problem without having me to do some hard programming.
The sample case can be seen in here: https://docs.google.com/spreadsheets/d/14vSAeZxEJTzbNLLYEiref6qt-CMqiVi8alheLcIBugM/edit?usp=sharing
Google form should show something a little bit like is shown in cell D1:E3.
Where customers can fill the form with their own customer id, and the google form shows the status.
Consideration
There is no way to respond back in a Google Form directly. You can't show custom validation messages after From submission either.
Proposed solution
What about using email addresses additionally to the customerID to retrieve the shipping status? In this way you can easily build a notification system that will send an email if a matching customer ID is found in your spreadsheet.
To build such system you will have to build a Form with a Trigger.
It is required a bit of programming but I will try to cover the most important parts the best I can:
Adapt your Database structure
Add the customers email addresses in the column C in order to be able to retrieve it using the same customer ID.
| A | B | C |
|----+--------+-------|
| ID | STATUS | EMAIL |
Build the Form Trigger
In the Form you are using click on the 3 dots from the top menu and select Script Editor. Here you will write the code that will power your notification system.
function installTrigger() {
// This function instructs the program to trigger the checkID function whenever a form response is submitted
ScriptApp.newTrigger('checkID')
.forForm(FormApp.getActiveForm())
.onFormSubmit()
.create();
}
function checkID(e) {
// This function will parse the response to use the customer ID to retrieve email address and shipping status from the Spreadsheet Database
var responses = e.response.getItemResponses(); // Gets the form responses
var id = responses[0].getResponse(); // Assuming the first answer (index 0) is the customer ID)
var found = SpreadsheetApp.openById('spreadsheet_id')
.getRange('Sheet1!A1:C8') // The spreadsheet cells range in A1 Notation
.getValues() // Retrieve their values in rows
.filter((row) => row[0] == id); // Filter the rows for the provided customer ID
if (found) {
var status = found[0][1]; //Column B
var email = found[0][2]; //Column C
var subject = "Shipping Status";
var message =
`Hello!
The status of the order number ${id} is: ${status}.`
MailApp.sendEmail(email, subject, message);
}
}
Install the trigger
From the Script Editor top menu run the installTrigger() function: Run>Run function>installTrigger.
You are done
Following these steps you have successfully set up the notification system. Now you can start sharing the Form link and accept responses.
References
Installable Triggers
Mail App

SharePoint Online Access Request Status Codes

I am using CSOM to retrieve items from the "Access Requests" list.
(https://sharepointSite.sharepoint.com/sites/siteName/Access%20Requests/pendingreq.aspx)
I am trying to figure out all the possible values of the "Status" field.
I have found the following values (just from looking at the access requests page and comparing to the data retrieved from my code)
0 = Pending
2 = Accepted
5 = Withdrawn
I have been unable to find any reference to these codes online.
Can anyone point me to a reference for these values or let me know what you figured our on your own?
OK whilst "_ModerationStatus" values are 0..4 (where 0=Approved), this is not the same as the "Status" field of an Access Request, which has values I have obtained from the Microsoft.SharePoint.SPAccessRequestsUtility (public enum StatusToInt), as well as accessrequestsviewtemplate.debug.js file (located in 15 hive, Layouts folder):
0=Pending (which could also trigger expired is an invitation)
1=Approved
2=Accepted
3=Denied
4=Expired
5=Revoked
I obtained this from powershell hitting the field and obtaining the SchemaXml property, reverse-engineering code as well as this MS link:
https://msdn.microsoft.com/en-us/library/jj675013(v=office.12).aspx
Also look at these links depending upon your need:
https://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spaccessrequests.changerequeststatus.aspx
https://msdn.microsoft.com/en-us/library/jj674880(v=office.12).aspx
Statuses are stored in Approval Status field (Internal Name: _ModerationStatus) for the specified Access Requests list
How to retrieve values of _ModerationStatus field via CSOM
var listTitle = "Access Requests";
var fieldName = "_ModerationStatus";
var list = ctx.Web.Lists.GetByTitle(listTitle);
var field = list.Fields.GetByInternalNameOrTitle(fieldName);
ctx.Load(field);
ctx.ExecuteQuery();
var fieldChoice = ctx.CastTo<FieldChoice>(field);
var values = fieldChoice.Choices;
foreach (var value in values)
{
Console.WriteLine(value);
}
About Moderation Status field
According to 2.2.1.2.13 Moderation Status the following are all possible valid values for Moderation Status:
0 - The list item is approved.
1 - The list item has been denied approval.
2 - The list item is pending approval.
3 - The list item is in the draft or checked out state.
4 - The list item is scheduled for automatic approval at a future date.

CRM 2011 oData query confusion

I am very new to CRM development, i was trying to follow this article, i am a bit confused about below code, please check:
var xp = Xrm.Page;
function onLoad(context) {
var accountId = xp.data.entity.getId();
var mostRecentQuery = "/XRMServices/2011/organizationData.svc/ContactSet?
$select=FullName,JobTitle,EMailAddress1,Telephone1&$top=1&$orderby=CreatedOn
desc&$filter=ParentCustomerId/Id eq guid'" + accountId + "'";
getContact(mostRecentQuery, "MostRecent");
....
}
The above javascript function executes when AccountForm is opened. The first line gets the accountId. the next line is oData query.
Now check the ContactSet in this query, i am confused here, how we can retrieve the ContactEntity based on the GUID of AccountEntity?
I found the answer!
Actually there a Lookup 'Parent Customer' on ContactEntity, it represents the unique identifier of the account or contact associated with this contact, so we can select an Account/Contact as the Parent Customer of a contact.
So this given OData query actually retrieves the top 1 contact where this account is referenced.
I hope its clear.

Query Trac for all tickets related to a user

How do I query for all trac tickets related to a user. i.e. all tickets for which the tickets were once assigned, assigned now, created , etc etc
Create custom queries to the ticket_change table. Some SQL required. For assigned once/now, look for rows where field='owner', newvalue column contains the user name the ticket was assigned to. For created tickets, just query by reporter in the ticket table.
Example:
SELECT p.value AS __color__,
id AS ticket, summary, component, version, milestone,
t.type AS type, priority, t.time AS created,
changetime AS _changetime, description AS _description,
reporter AS _reporter
FROM ticket t, enum p, ticket_change c
WHERE p.name = t.priority AND p.type = 'priority'
AND c.field = 'owner'
AND c.newvalue = '$USER'
AND c.ticket = t.id
ORDER BY p.value, milestone, t.type, t.time
You can express this with a TraqQuery expression. E.g. if you want the columns id, summary and status to show up and query all the tickets for the currently logged in user ($USER) then use the following query.
query:?col=id
&
col=summary
&
col=status
&
owner=$USER
However this query assumes that the owner hasn't been the same during the lifetime of a ticket (since ownership can be changed).
If you want a specific user then replace $USER with the actual username. Also if you're using the Agilo plugin you can easily create new queries on the fly via the web-UI. This is done by looking at a report and adding filters to the report.

Resources