Kofax Export Connector - get value from IndexField - c#

I created a mapping for my Kofax Export Connector. This connector interacts with an external application using webservices.
I want to connect the indexfield values to field IDs of the external application. Currently I have a dictionary containing the ID of the external application and the index field ID.
Dictionary<double, double?> // external fieldID <-> indexfieldID
The key is nullable because a field might not be assigned. Instead of passing the indexfieldID to the external application I want to pass in the value of this indexfield.
Currently I have this
releaseSetupData.CustomProperties.Add("MetaFieldID", "IndexFieldID");
and the desired result would be
releaseSetupData.CustomProperties.Add("MetaFieldID", "IndexFieldValue");
How do I get the value of the index field? The indexfield itself has no "value" property and the Kofax user is able to setup a custom field with a custom dataType. So how would a value look like?
I don't get it from the Kofax Capture Export Type Library API Reference Guide

Generally speaking, Kofax organizes any kind of mapped data as so-called Links. However, it does not take care of mapping anything on its own, that is our job (for some reason). You will find two different objects at your disposal:
Your setup script will contain a reference to a ReleaseSetupData object, usually named SetupData.
Your release script has another reference to a ReleaseData object, namely DocumentData.
Now, all links established during setup time will become available during release time. Said links can contain different kinds of data, for example index fields, batch fields, Kofax values, or custom properties. Now, let's say you have the index field "FirstName" on your document class, and you do want to access its value during release time - here's what you need to do.
Setup Script
setupData.Links.Add(
setupData.IndexFields["FirstName"].Name,
KfxLinkSourceType.KFX_REL_INDEXFIELD,
setupData.IndexFields["FirstName"].Name);
setupData.Apply();
Please keep in mind that those links are similar to dictionary entries, so you can't link the same item twice. I usually like removing all links when my setup script loads, and add them again when it unloads again (and note that you can safely loop over the setupData.Indefields collection to add all fields instead of just a single one).
Release (Run) Time
During release, all links are then made available in the DocumentData.Values collection. To access your index field and its value, here's what you need to do. The following assumes you already set up a Dictionary<string, string> named IndexFields, and it further shows you how to access all other kinds of links (batch fields, custom properties, et cetera):
foreach (Value v in DocumentData.Values)
{
switch (v.SourceType)
{
case KfxLinkSourceType.KFX_REL_BATCHFIELD:
BatchFields.Add(v.SourceName, v.Value);
break;
case KfxLinkSourceType.KFX_REL_DOCUMENTID:
break;
case KfxLinkSourceType.KFX_REL_INDEXFIELD:
// index fields may also contain table fields
if (v.TableName == "")
{
// this is a regular index field
IndexFields.Add(v.SourceName, v.Value);
}
else
{
// this is a table field!
}
break;
case KfxLinkSourceType.KFX_REL_TEXTCONSTANT:
TextConstants.Add(v.SourceName, v.Value);
break;
case KfxLinkSourceType.KFX_REL_UNDEFINED_LINK:
break;
case KfxLinkSourceType.KFX_REL_VARIABLE:
break;
}
}
If you wanted to map Kofax Index Fields to some external ID, you could safely do so using Custom Properties. Example: you can assign the id 42 to FirstName during setup (just create a property grid with a custom class), add the Custom Property during setup time, and then access its value during release. That way you could maintain ids via the setup form without the need to ever rebuild your solution.

Related

Extension function parameters or return values which have Clr type 'XmlQualifiedName' are not supported trying to use FILE.ReceivedFileName

I am creating import application using BizTalk.
I have created File schema and Database tables schema and map those schemas as below:
Also, I want Filename into the table so I created scripting functiod and its scripts as below:
Now I am validating and testing map but it is giving me below error:
Extension function parameters or return values which have Clr type 'XmlQualifiedName' are not supported.
Please see below SS for Orchestration:
As it looks you might have some repeating nodes, and you can't promote or distinguish a field that occurs multiple times, do the following.
Create an internal schema where the fname only occurs once.
Distinguish that field by right clicking anywhere on the schema tree, select Promote, Show Promotions
Select the field to distinguish (e.g. fName), make sure the tab is in Distinguished Fields (the default), click the Add button, click the OK Button
Have a map from your rcv_msg to the internal_msg wich either sets a default value to that field or use a functoid like the String Concatenate to set a default value. This is so that the map creates that element.
Inside your construct shape in your Orchestration add a Message Assignment shape following your transform shape.
In the assignment shape have code like the following internal_msg.fName = rcv_msg(FILE.ReceivedFileName);
Map from the internal schema to your snd_msg, you can either execute that in the Orchestration or in the Send Port.

Initializing a custom field that is defined but empty by default?

so in our Jira, we have a custom field "X" that is empty by default. To my surprise, it is not returned at all when listing through CustomFields of a newly created issue, and therefore I cannot simply use:
issue.CustomFields["X"].Values == ...
because such a field would not be found.
It only becomes available in the RestAPI when a user enters some data via Jira UI. However, I would need to be able programmatically to initialize this field in certain cases but I cannot figure out how.
EDIT:
I test if the field is there:
if (x.CustomFields.Where(CustomField => CustomField.Name=="X").Count()==0)
{
//NOT FOUND - I need to initialize it (cannot just set its value for the reasons stated above}
}
Thanks a lot

TFS SDK - How can I tell what fields were changed in a revision?

I need to tell which fields were changed as part of a revision. At the moment I'm checking using
foreach (Field f in revision.Fields) {
if (Equals(f.OriginalValue, f.Value)) { continue; }
// do something with changed field
}
however, this code has an issue and that is that it doesn't list fields, which were changed but to the same value. Looking at https://msdn.microsoft.com/en-us/library/microsoft.teamfoundation.workitemtracking.client.revision(v=vs.120).aspx I don't see a way to do so, but since TFS does track this kind of thing (== visual studio & web interface both shows changed fields even to the same value), it should be possible. But I have no idea how to do so.
The history value couldn't be changed by this way: work_item.fields["History"] = "value". Workitem History are not support to changed and modified. It generates according to what you have edit on this workitem.
And this if (Equals(f.OriginalValue, f.Value)) { continue; } won't list the history field. The history field is not simple like other fields(Priority, title,etc). The Revisions represent History of workitems.
Update:
To get which fields changed in each revisions, you could try to list all info in the revisions and write method to compare them. This is an example:
http://geekswithblogs.net/TarunArora/archive/2011/08/21/tfs-sdk-work-item-history-visualizer-using-tfs-api.aspx

What to use instead ini in C#

There must be a program that should generate WORD document (but that's not the point). It generates a document by data that the user writes in the program. And sometimes there is need to close application and do some other work and user don't want to lose all progress. And here we must keep all the "changes" that user have entered. Previously, I have saved all .ini file (under the instruction http://www.codeproject.com/Articles/1966/An-INI-file-handling-class-using-C) it was enough for me for test, but in real cases ini was not enough, because if I save the textbox with multiline so record to inin file goes wrong, and when reading ini file - readed was only the first line and then only the first 255 characters.
Here is an example of what should be saved:
information about all checked checkboxes radiobuttons etc. (in
INI-expample I show it in CHECKOUTS and COMPARING sections)
the data from all textboxes on the main form (MAIN section)
most importantly, objects of 'implementation' and 'screens' class.
Now about class 'implementation': Each implementation may have a name, description, status, and a list of links to screenshots. To do this, I created a listbox with list of screenshots for each implementation (ScreenList) and a separate listbox for all implementations. Ie when I fill the data I store object in listbox, and then if I need I can just get access to it. And when I save a list of all implementations into ini I first of all write the number of all implementations to be able get access in loops (for, while etc) to each object (all in INI and CODE examples: Section IMPLEMENTATIONS, IMPLEMENTATION_n ...)
And the question is: how to save these Data? As I know Microsoft has abandoned ini and use the xml, but I can't google it correctly. Someone suggested I use serialization of data in xml, but as far as I could google - Serialization is used only for one object of class, and I have a lot of these objects are, othervide I still have and values ​​of all the checkboxes and more. Ie I need to save all the values ​​of controls , all the objects of classes implement and screen, and then read these values ​​and write them right back to where they were taken . How to do that?
Code examples:
//........save object to listbox
Implement imp = new Implement(impName.Text, impDescr.Text, impStatus.Text, ScreenList);
listBox1.Items.Add(imp);
//......
//in implement class, Screens is list of screenshots that is get from another listbox
private List<string> _Screens = new List<string>();
public Implement(string Name, string Description, string Status, ListBox Screen)
{
_Name = Name;
_Description = Description;
_Status = Status;
for(int i=0;i<Screen.Items.Count;i++)
{
_Screens.Add(Screen.Items[i].ToString());
}
}
//....getting access to implementation
Implement imp = (Implement)listBox1.SelectedItem;
....
Ini example:
[MAIN]
Languages=Polish
Comment=Comment lalarar larl alrlalrl
Status=Correct
[CHECKOUTS]
Enable=True
SLDoc=False
SLDocTab=True
SaveDoc=True
LoadDoc=False
SendDoc=False
Correctly=True
CorrNum=50
[COMPARING]
Enable=True
NoDif=False
Declar=True
UnDecl=False
UnDeclDESCR=
[IMPLEMENTATIONS]
COUNT=2
[IMPLEMENTATION_0]
Name=Implement 1 CORRECT
Descr=text text test text
Status=Correct
ScreenCount=2
Screen_0=C:\1.png
Screen_1=C:\2.png
[IMPLEMENTATION_1]
Name=IMPLEMENT 2 INCORRECT
Descr=lala
Status=Incorrect
ScreenCount=2
Screen_0=C:\2.png
Screen_1=C:\3.jpg
[SCREENS]
COUNT=2
[SCREEN_0]
Descr=Screen 1
Screen=C:\1.png
[SCREEN_1]
Descr=Screen 2
Screen=C:\1.png
If I understood you correctly you should take a look at settings mechanism in c#.
I hope that this chapter of MSDN will be useful.
What you have to do is create some kind of Settings object. This should be a class that either has a specific property (or class for nested values) for each setting you like (e.g. public string Language {get; set; }) or you take a more generic way by using two dictionaries Dictionary<string, string> (for simple values), Dictionary<string, Settings> (a recursive structure for complex types).
Then your form should be able to create such a settings object an fill it with the desired data it needs to recreate the current state and it should be able to take such a settings object and change its current state to this settings object by setting all inner variable to the values within this object.
The next step would be to make this object serializable by either using XML serialization or Data Contract or whatever you like. Then you can write/load this object to/from disk and afterwards push it into the class that needs this state.

Sharepoint External Data - multi value field

I need to create a list field which contains external datas (from BDC). The field has to contain multiple values. But I didn't found a way how to make a external-data-field taking multiple values.
Creating such a multivaluefield from User-Contetntype is possible by using the Column-Properties. By creating a column from external data I do not have the possibility to activate multi-value mode.
It should look like this, just from a external data source (BDC):
Does anyone know how handle such a situation?
What TypeName is your TyperDescriptor? Set it to an Array of a type.
Eg.
<TypeDescriptor Name="somename" TypeName="System.String[]" />
If you're changing the type of an existing crawled property, you need to delete it first.
Unmap it from all managed properties, exclude property from search index and delete on the Business Data category. Reset index and IISRESET.
Do a full crawl and your crawled property is now multivalued (Variant Type 4127).

Categories

Resources