SOAPpy - create a Jira issue and define a component? - jira

I can't figure how to create a jira issue and define its component with SOAPpy:
client = so.WSDL.Proxy(cfg_wsld)
auth_token = client.login(cfg_username, cfg_password)
issue_params = dict()
issue_params['project'] = project
issue_params['type'] = issue_type
issue_params['summary'] = summary
issue_params['description'] = summary
newissue = client.createIssue(auth_token, issue_params)
This sample works fine but I try to add components to it Jira will return missmatchTypeException.
I've tried all kinds of variants: passing arrays, strings, ints into it but it won't pick any of them up.
Most attempts (passing string, int, array of both) will cause TypeMissmatch, this causes NullPointerException inside Jira:
issue_params['components'] = {u'Разное': {'id': '11143', 'name': u'Разное'}}
I know the exact id of the issue type I want to use but how do I pass it properly? When I retrieve an issue with this type components returns as SOAPpy.Types.typedArrayType() but this still fails:
issue_params['components'] = so.Types.typedArrayType(data={'id': '11143', 'name': u'Разное'})
newissue = client.createIssue(auth_token, issue_params)
(<class 'SOAPpy.Errors.Error'>, <Error : Data must be a sequence>, None)

issue_params['components'] = so.Types.typedArrayType(data=[{'id': '11143', 'name': u'Разное'},])
This did the trick - data needs to be an array.

Related

Create Deep Entity SAPUI5 - Item Data Not Transmitted

I used to the following tutorial to build a Fiori app with a deep entity (I used invoice header + items): https://blogs.sap.com/2017/07/18/steps-to-create-deep-insert-odata/
Everything works fine until I start debugging in the backend. The service sends the data correctly, in the backend, however, the items are missing. Backend code:
METHOD /iwbep/if_mgw_appl_srv_runtime~create_deep_entity.
DATA custom_create_deep_entity TYPE zcl_xxx_mpc_ext=>ts_deep_entity.
CASE iv_entity_set_name.
WHEN 'xxxSet'.
CALL METHOD me->custom_create_deep_entity
EXPORTING
iv_entity_name = iv_entity_name
iv_entity_set_name = iv_entity_set_name
iv_source_name = iv_source_name
it_key_tab = it_key_tab
it_navigation_path = it_navigation_path
io_expand = io_expand
io_tech_request_context = io_tech_request_context
io_data_provider = io_data_provider
IMPORTING
er_deep_entity = custom_create_deep_entity.
copy_data_to_ref(
EXPORTING
is_data = custom_create_deep_entity
CHANGING
cr_data = er_deep_entity
).
ENDCASE.
ENDMETHOD.
METHOD custom_create_deep_entity.
DATA: lr_deep_entity TYPE zcl_xxx_mpc_ext=>ts_deep_entity,
lt_items TYPE zcl_xxx_mpc=>tt_zinvoiceitem,
ls_items TYPE zcl_xxx_mpc=>ts_zinvoiceitem.
io_data_provider->read_entry_data(
IMPORTING
es_data = lr_deep_entity ).
ls_header_input = VALUE #(
bukrs = lr_deep_entity-bukrs
wrbtr = lr_deep_entity-wrbtr
).
LOOP AT lr_deep_entity-items ASSIGNING FIELD-SYMBOL(<ls_item>).
"never reached because 'items' is empty
ENDLOOP.
er_deep_entity = VALUE #(
bukrs = ls_header_input-bukrs
wrbtr = ls_header_input-wrbtr
items = lr_deep_entity-items
).
ENDMETHOD.
Redefined DEFINE method in class MPC_EXT:
METHOD define.
super->define( ).
DATA:
lo_annotation TYPE REF TO /iwbep/if_mgw_odata_annotation,
lo_entity_type TYPE REF TO /iwbep/if_mgw_odata_entity_typ,
lo_complex_type TYPE REF TO /iwbep/if_mgw_odata_cmplx_type,
lo_property TYPE REF TO /iwbep/if_mgw_odata_property,
lo_entity_set TYPE REF TO /iwbep/if_mgw_odata_entity_set.
lo_entity_type = model->get_entity_type( iv_entity_name = 'Zxxxxxx' ).
lo_entity_type->bind_structure( iv_structure_name = 'ZCL_XXX_MPC_EXT=>TS_DEEP_ENTITY' ).
ENDMETHOD.
Do I need to redefine any other methods that prohobit transferring the item data?
Thanks :)
How does the structure zcl_xxx_mpc_ext=>ts_deep_entity. looks like ?
Change the names of the navigations and the underlying structure name for the navigation according to the types mentioned in Types tab in ‘__MPC_EXT’ class of your project. [Source]
How does your payload look like while calling the Service ?
If the payload look's right you clearly have a problem with your structure ts_deep_entity
Review your ts_deep_entity. Make sure your deep structure or table type name inside is identical to your entity sets from segw data model.

Docusign API Ruby: How to set predefined Custom Fields for an Envelope creation?

I created some enveloppe custom fields in the admin of Docusign.
So I'd to know how to set their value when I create an enveloppe from the docusign Ruby API.
I've tried to set there like this, but it doesn't work. When I send the envelope the custom fields are not filled.
envelope_definition = DocuSign_eSign::EnvelopeDefinition.new
custom_fields = DocuSign_eSign::CustomFieldsEnvelope.new(
{"name":"enveloppe_annee","value":"2019"}
)
envelope_definition.custom_fields = [custom_fields]
The envelope_definition.custom_fields attribute takes a single instance of custom_fields. (Not an array)
custom_fields is an object that has two attributes:
list_custom_fields wants an array of ListCustomField
text_custom_fields wants an array of TextCustomField
Based on the above, can you redo your request?
envelope_definition = DocuSign_eSign::EnvelopeDefinition.new({status: 'sent', templateId:'a19dXXXX-XXXX-4ce7-XXXX-56cXXXX83364', emailSubject: 'Example Document Signing'})
signer = DocuSign_eSign::TemplateRole.new({email: 'email#eample.com', name: 'Johny Walker', roleName: 'signer'})
text = DocuSign_eSign::Text.new
text.tab_label = 'label_id of the custom field'
text.value = 'value for the custom field'
tabs = DocuSign_eSign::Tabs.new
tabs.text_tabs = [text]
signer.tabs = tabs
envelope_definition.template_roles = [signer]
This should work for you

Adwords API report segmenting

i'm trying to create google adwords report that will gain me
clicks,shows,cost,bounce,goal reach count
for each:
ad id, pharse id, goal id, day
(like group by)
There are a lot of different report types and i can't get how to create that kind of report.
Im using googleads-php-lib, so here is the code from example:
$selector = new Selector();
$selector->fields = array('Id', 'Clicks', 'Cost');
// Optional: use predicate to filter out paused criteria.
//$selector->predicates[] = new Predicate('Status', 'NOT_IN', array('PAUSED'));
// Create report definition.
$reportDefinition = new ReportDefinition();
$reportDefinition->selector = $selector;
$reportDefinition->reportName = 'Criteria performance report #' . uniqid();
$reportDefinition->dateRangeType = 'LAST_90_DAYS';
$reportDefinition->reportType = 'AD_PERFORMANCE_REPORT';
$reportDefinition->downloadFormat = 'CSV';
Sometimes you can't get all data in the same report. You can see all the report types in the AdWords Docs:
https://developers.google.com/adwords/api/docs/appendix/reports
You can add Segment in selector->fields
Example: ClickType is a segment so it will be implemented as given below.
$selector->fields = array('Id', 'Clicks', 'Cost', 'ClickType');
or with CriteriaReportWithAwql
$query = (new ReportQueryBuilder())
->select([
'CampaignId',
'CampaignName',
'Impressions',
'Clicks',
'Cost',
'ClickType',
'AccountCurrencyCode',
])
->from(ReportDefinitionReportType::CRITERIA_PERFORMANCE_REPORT)
->where('Status')->in(['ENABLED', 'PAUSED'])
->where('CampaignId')->in(['90045151'])
->during($startDate, $endDate)
->build();

Adding Array like data in Zend Framework 2 Sessions

Im wondering how to achieve the following:
I have this Session Container created by a factory:
$container = new Container('Fans');
$container->setExpirationSeconds('219867583');
return $container;
then i'm creating an instance in my controller like this:
$this->sessionService = $this->getServiceLocator()->get('SessionService');
Now i want to add something to the Session:
This one works fine:
$this->sessionService->team = 'TEST';
But what i want to achieve is the following
$this->sessionService->team[0] = 'Team Name 0' // This doesn't work;
$this->sessionService->team[1] = 'Team Name 1' // This doesn't work;
\Zend\Debug\Debug::dump($this->sessionService->team);
The Output looks like this:
<pre>string(9) "TEST" </pre>
I don't know if i misunderstood something or do something wrong.
Does anybody know how to do it right ?
This is a problem with the magic __get() functionality in PHP. Because Zend\Session uses __get() to supply access to session variables, you cannot access them like arrays. What does work, is the following:
$team = array();
$team[0] = 'Team Name 0';
$team[1] = 'Team Name 1';
$this->sessionService->team = $team;
How about using an array?
$teams = array();
$session->teams = $teams;
$session->teams[0] = 'blubb';
If you first assign it to be a string, it will remain a string. Make it an array and use it as an array, too ;)

Update custom cascading select field in JIRA via suds

Using JIRA version 4.2. With Python 2.7 and suds 0.4, how can I update an issue's custom cascading select's field (both parent and child)?
There is a SOAPpy example available under "Python (SOAPPy) client".
I was unable to perform this type of update using the Python JIRA CLI.
Example:
When updating the cascading select custom child of parent field, customfield_10, one would want to update the field customfield_10_1.
Update
Code to display cascading field's original value:
issue = client.service.getIssue(auth, "NAHLP-33515")
for f in fields:
if f['customfieldId'] == 'customfield_10050' or f['customfieldId'] == 'customfield_10050_1':
print f
This results in:
(RemoteCustomFieldValue){
customfieldId = "customfield_10050"
key = None
values[] =
"10981",
}
After manually setting the cascading field's child, the above code results in:
(RemoteCustomFieldValue){
customfieldId = "customfield_10050"
key = None
values[] =
"10981",
}
(RemoteCustomFieldValue){
customfieldId = "customfield_10050"
key = "1"
values[] =
"11560",
}
The above values is what I hope to achieve via suds.
Note the key = "1" field. The key value designates that this object is the child of customfield_10050.
Documentation reference:
parentKey - Used for multi-dimensional custom fields such as Cascading select lists. Null in other cases
Let's try sending a key field value:
client.service.updateIssue(auth, "NAHLP-33515", [
{"id":"customfield_10050", "values":["10981"]},
{"id":"customfield_10050_1", "key":"1", "values":["11560"]}
])
This results in an error because the updateIssue accepts a RemoteFieldValue[] parameter, not a RemoteCustomFieldValue[] parameter (thanks Matt Doar):
suds.TypeNotFound: Type not found: 'key'
So how do we pass a RemoteCustomFieldValue parameter to update an issue?
Update 2, mdoar's answer
Ran following code via suds:
client.service.updateIssue(auth, "NAHLP-33515", [
{"id":"customfield_10050", "values":["10981"]},
{"id":"customfield_10050_1", "values":["11560"]}
])`
After value:
(RemoteCustomFieldValue){
customfieldId = "customfield_10050"
key = None
values[] =
"10981",
}
Unfortunately, this does not update the child of customfield_10050. Verified manually.
Resolution:
Thank you mdoar! To update a parent and child of a cascading select field, use the colon (':') to designate the child filed.
Working example:
client.service.updateIssue(auth, "NAHLP-33515", [
{"id":"customfield_10050", "values":["10981"]},
{"id":"customfield_10050:1", "values":["11560"]}
])

Resources