Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to extract custom fields using incremental export. Custom fields are excluded from return type model. #310

Closed
dkholo opened this issue Nov 9, 2017 · 23 comments

Comments

@dkholo
Copy link

dkholo commented Nov 9, 2017

Unable to extract custom fields using incremental export. Custom fields are excluded from return type model. When I query ZenDesk API directly I am able to to get the fields, but when I am trying to use ZenDeskApi_v2 they are omitted. What is the best strategy of incremental extraction for custom fields?
I would Greatly appreciate your help. I was trying to override the model, but I am getting compilation error in VS2017:
Severity Code Description Project File Line Suppression State
Error MSB4044 The "GetAssemblyVersion" task was not given a value for the required parameter "NuGetVersion". ZendeskApi_v2 C:\Program Files\dotnet\sdk\2.0.2\Sdks\Microsoft.NET.Sdk\build\Microsoft.NET.GenerateAssemblyInfo.targets 146

I sincerely hope this issue can be addressed or a work around can be proposed.

Dmitry Kholodkov

@dkholo
Copy link
Author

dkholo commented Nov 9, 2017

All dependencies in API solution are broken.
Did I miss an additional step for solution activation?

@dkholo
Copy link
Author

dkholo commented Nov 9, 2017

I was able to compile the solution by re-cloning and using VS2015. What is my next step for attempting to address custom field extraction issue?

@dkholo
Copy link
Author

dkholo commented Nov 9, 2017

I think the fact that I am using api version 2.5.5 could be contributing to the problem.
I still would greatly appreciate some help in determining the best strategy of incremental export with custom fields.

@WinDrop
Copy link
Contributor

WinDrop commented Nov 10, 2017

Are you simply looking for a way to extract Ticket Field information (Built-in as well as custom fields)?

@dkholo
Copy link
Author

dkholo commented Nov 10, 2017

Correct. I wold like to extract complete ticket information. ( all fields with the values )

@dkholo
Copy link
Author

dkholo commented Nov 10, 2017

Field name look up process is not clear given we are not able to query api for each ticket ( due to Zendesk api access policy )

@WinDrop
Copy link
Contributor

WinDrop commented Nov 10, 2017

So This is what I have in my code

Selecting tickets since last query
tickets = Zendesk.Tickets.GetIncrementalTicketExport(LatestScan.ScanDateTime, ZendeskApi_v2.Requests.TicketSideLoadOptionsEnum.Groups | ZendeskApi_v2.Requests.TicketSideLoadOptionsEnum.Last_Audits | ZendeskApi_v2.Requests.TicketSideLoadOptionsEnum.Metric_Sets | ZendeskApi_v2.Requests.TicketSideLoadOptionsEnum.Organizations | ZendeskApi_v2.Requests.TicketSideLoadOptionsEnum.Ticket_Forms | ZendeskApi_v2.Requests.TicketSideLoadOptionsEnum.Users);

Process each ticket

            foreach (ZendeskApi_v2.Models.Tickets.Ticket Ticket in tickets.Tickets)
            {
                Classes.ZendeskTickets.InsertOrUpdateTicket(Ticket);
            }

Go through every ticket audit and audit event (Audit Events hold Ticket Fields)

                    foreach (ZendeskApi_v2.Models.Shared.Audit TicketAudit in Audits.Audits)
                    {

                            foreach (ZendeskApi_v2.Models.Shared.Event AuditEvent in TicketAudit.Events)
                            {
                                string AuditEventFieldValue = null;
                                if (!string.IsNullOrEmpty(AuditEvent.FieldName))
                                {
                                    if (AuditEvent.FieldName.All(Char.IsDigit))
                                    {
                                        TblTicketFieldOption value = db.TblTicketFieldOptions.Where(to => to.intTicketFieldID == Convert.ToInt64(AuditEvent.FieldName) && to.txtValue == (object.ReferenceEquals(null, AuditEvent.Value) ? "" : AuditEvent.Value.ToString()) && to.TblTicketField.txtType == "tagger").FirstOrDefault();
                                        AuditEventFieldValue = (value == null ? null : value.txtName);
                                    }
                                }
                            }
                        }

At this point, AuditEvent.FieldName will contain one of the following 2
string = Built-in field
Integer = Custom Field meaning that you will have to lookup it's name in Zendesk.Tickets.GetTicketFields().TicketFields (Has to be queried separately)

Hope this helps

@dkholo
Copy link
Author

dkholo commented Nov 10, 2017

when I upgrade the nuget package I have compilation errors:
Severity Code Description Project File Line Suppression State
Error CS0246 The type or namespace name 'TicketExportResponse' could not be found (are you missing a using directive or an assembly reference?) ZendeskTicketExporter.Core C:\Users\dkholo\Downloads\zendesk-ticket-exporter-master\zendesk-ticket-exporter-master\src\ZendeskTicketExporter.Core\ITicketRetriever.cs 8 Active

@dkholo
Copy link
Author

dkholo commented Nov 10, 2017

I still do not see custom fields in the Ticket model. I was hoping it would be there.

@WinDrop
Copy link
Contributor

WinDrop commented Nov 10, 2017

Customer fields are not stored separately.
They are stored together with the built-in fields.
Query Zendesk.Tickets.GetTicketFields().TicketFields and you will get all your fields.
Then it's just a matter of matching the IDs from AuditEvents to the custom field IDs as I explained in my example.

@dkholo
Copy link
Author

dkholo commented Nov 10, 2017

The example helps. I was hoping to avoid doing ticket by ticket processing. I am getting the collection if I query Zendesk ticket API directly without wrapper:
custom_fields":[{"id":80933188,"value":"master Version 2016 (Build 17.3.6982.0821) (Placeholders)"},
{"id":81014788,"value":"en-us"},
{"id":80534707,"value":"migration_do_not_handle"},
{"id":81014608,"value":"item1"}
,{"id":80625367,"value":false}
,{"id":80544147,"value":null}

@WinDrop
Copy link
Contributor

WinDrop commented Nov 10, 2017

This is the data from Audit Events. You will get this same collection there.
You then have to match these IDs to result from GetTicketFields() method which will provide you the fields name.

@dkholo
Copy link
Author

dkholo commented Nov 10, 2017

when using raw json I could potentially build custom field metadata mapping and use for interpretation of ids . Not sure if it is viable stratergy.

@dkholo
Copy link
Author

dkholo commented Nov 10, 2017

strategy*

@WinDrop
Copy link
Contributor

WinDrop commented Nov 10, 2017

I just create a TicketField array at the very beginning of my script and then compare IDs from Audit Events to an item within the array to avoid querying API for every field.

@dkholo
Copy link
Author

dkholo commented Nov 10, 2017

I wold greatly appreciate some help addressing the version 2.55 to 3.7 upgrade error:
Severity Code Description Project File Line Suppression State
Error CS0246 The type or namespace name 'TicketExportResponse' could not be found (are you missing a using directive or an assembly reference?) ZendeskTicketExporter.Core C:\Users\dkholo\Downloads\zendesk-ticket-exporter-master\zendesk-ticket-exporter-master\src\ZendeskTicketExporter.Core\ZendeskApi.cs 22 Active

Severity Code Description Project File Line Suppression State
Error CS7036 There is no argument given that corresponds to the required formal parameter 'locale' of 'ZendeskApi.ZendeskApi(string, string, string, string, string, string)' ZendeskTicketExporter.Core C:\Users\dkholo\Downloads\zendesk-ticket-exporter-master\zendesk-ticket-exporter-master\src\ZendeskTicketExporter.Core\ZendeskApi.cs 15 Active

@WinDrop
Copy link
Contributor

WinDrop commented Nov 10, 2017

I haven't upgraded my code for at least a year. Not sure which version I am on :) Cannot help you here mate

@dkholo
Copy link
Author

dkholo commented Nov 10, 2017

Array is a great idea.

@dkholo
Copy link
Author

dkholo commented Nov 10, 2017

Thank you for your help.
You are still one a newer version. Side loading is not available for me:
api.Tickets.GetInrementalTicketExportAsync(marker.Value.FromUnixTime());
call uses only a single parameter.

What type is tickets in your sample?

@WinDrop
Copy link
Contributor

WinDrop commented Nov 10, 2017

Ticket is a static property. Here is the code
static private ZendeskApi_v2.Models.Tickets.GroupTicketExportResponse tickets;

@dkholo
Copy link
Author

dkholo commented Nov 10, 2017

Still an opened question:
Error CS0246 The type or namespace name 'TicketExportResponse' could not be found (are you missing a using directive or an assembly reference?) ZendeskTicketExporter.Core C:\Users\dkholo\Downloads\zendesk-ticket-exporter-master\zendesk-ticket-exporter-master\src\ZendeskTicketExporter.Core\ZendeskApi.cs 22 Active

Severity Code Description Project File Line Suppression State
Error CS7036 There is no argument given that corresponds to the required formal parameter 'locale' of 'ZendeskApi.ZendeskApi(string, string, string, string, string, string)' ZendeskTicketExporter.Core C:\Users\dkholo\Downloads\zendesk-ticket-exporter-master\zendesk-ticket-exporter-master\src\ZendeskTicketExporter.Core\ZendeskApi.cs 15 Active

on this line that works well with 2.55

@dkholo
Copy link
Author

dkholo commented Nov 10, 2017

return new TicketExportResponse()
{
EndTime = marker.Value,
Results = new List(),
};

@dkholo
Copy link
Author

dkholo commented Nov 10, 2017

The issue was related to the versioning. I am able to see the custom field collection after upgrading API version from 2.55 to 3.7.
Thank you WinDrop for your help with this question.

@dkholo dkholo closed this as completed Nov 10, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants