VWAttachment added through API is not showing in CM 5.2 - filenet-p8

I have retrieved a workitem using API and changed the attachment fields using setParameterValue , After saving the work usingstepElement.doSave(true), I can see the added attachments in the process tracker through process administration console , but my problem is it is not showing up in case navigator and in workplaceXT also it is saying "Attachment may be corrupted or deleted"
below is the code i used to create attachment
tempAtt.setAttachmentName("check.png");
tempAtt.setAttachmentDescription("Added by code");
tempAtt.setType(VWAttachmentType.ATTACHMENT_TYPE_DOCUMENT);
tempAtt.setLibraryType(VWLibraryType.LIBRARY_TYPE_CONTENT_ENGINE);
tempAtt.setLibraryName("TOS");
tempAtt.setId(doc.getVersionSeries().getId());
tempAttA[0] = tempAtt;
stepElement.setParameterValue("Zip", tempAttA, true);
I dont understand where i am wrong , please suggest.
//Filenet p8 5.2 , Content Platform Engine

Got the solution after banging my head for a couple of hours , posting the entire code , may be helpful for others
//Connect to PE
//Query the queue with wobnum and get the workobject
queryIndex = "F_WobNum";
queryMin[0] = wob;
queryMax[0] = wob;
queryFlag = VWQueue.QUERY_MIN_VALUES_INCLUSIVE + VWQueue.QUERY_MAX_VALUES_INCLUSIVE;
queryType = VWFetchType.FETCH_TYPE_WORKOBJECT;
queryTypeStepElement = VWFetchType.FETCH_TYPE_STEP_ELEMENT;
queue = session.getQueue("Queue_Name");
query = queue.createQuery(queryIndex, queryMin, queryMax, queryFlag, null, null, queryType);
System.out.println("count " + query.fetchCount());
workObject = (VWWorkObject) query.next();
//get the stepelement
stepElement = workObject.fetchStepElement();
parameters = stepElement.getParameters(VWFieldType.ALL_FIELD_TYPES, VWStepElement.FIELD_USER_AND_SYSTEM_DEFINED);
//get the existing attachment value
tempAttA= (VWAttachment[]) stepElement.getParameterValue("attachment_field_name");
//attachment is VWAttachment array
attachment=tempAttA;
//lock the item for working
stepElement.doLock(true);
//set the new values for the new attachment to be added
tempAtt=new VWAttachment();
tempAtt.setAttachmentName("Attachment_name");
tempAtt.setAttachmentDescription("Added by code");
tempAtt.setType(VWAttachmentType.ATTACHMENT_TYPE_DOCUMENT);
tempAtt.setLibraryType(VWLibraryType.LIBRARY_TYPE_CONTENT_ENGINE);
tempAtt.setLibraryName("TOS");
//vs id of the existing CE document , note that adding attachment means refering a CE object , so the document u want to attach should be stored in CE before.
tempAtt.setId(doc.getVersionSeries().getId());
attachment=tempAttA;
//law is a arraylist of VWAttachment type , so u dont override any existing attachments
law.add(attachment[0]);
law.add(tempAtt);
//set the attchment field with new values
stepElement.setParameterValue("attachment_name", law.toArray(), true);

Related

cron job with php-ews to get only new emails from Exchange server

I need a cron job to obtain only the new emails received in a Exchange server since the last time it synchronized.
I coded the same with imap servers, and it was easy to get the emails since an ID. So I save the last ID at the end of the for cycle to the DB, and resume from that ID the next time the cron job executes.
I tried the same in Exchange, but I get the following error:
Failed to search for messages with "ErrorInvalidValueForProperty: El valor especificado no es válido para la propiedad."
To get the ItemId in Exchange I'm using the following code, with no error:
$item->ItemId->Id;
It returns something like:
AAMkADk3ZWRhY2VmLTdiY2UtNDkxYy04ZDMyLWZiZWIyYTQ4ZjQyMABGAAAAAAChH5wDkXAqTZaoH1oRodz8BwD8BvGliMkPTK/cnnmZJDPUAAAAvGXfAAD8BvGliMkPTK/cnnmZJDPUAAAAvJN5AAA=
To find the emails I'm trying the following code (with the error mentioned before):
$request = new FindItemType();
$request->ParentFolderIds = new NonEmptyArrayOfBaseFolderIdsType();
$request->Traversal = ItemQueryTraversalType::SHALLOW;
$greater_than = new IsGreaterThanOrEqualToType();
$greater_than->FieldURI = new PathToUnindexedFieldType();
$greater_than->FieldURI->FieldURI = UnindexedFieldURIType::ITEM_ID;
$greater_than->FieldURIOrConstant = new FieldURIOrConstantType();
$greater_than->FieldURIOrConstant->Constant = new ConstantValueType();
$greater_than->FieldURIOrConstant->Constant->Value = $UID;
Thanks!!
The EWS ItemId isn't a searchable property because it doesn't need to be eg you can just Bind to the Id in question to see if the Item exists. If it nolonger exists then you will get a specific error to tell you that. The SyncFolderItems operation is probably a more appropriate method to use however https://learn.microsoft.com/en-us/exchange/client-developer/web-service-reference/syncfolderitems-operation.

How do I add an iCal event using JS automation in OS X Yosemite?

I'm really having a hard time understanding how to interact with iCal using the new support for Javascript automation in Yosemite. I'm not too experienced with OOP so that might be where my problem lies.
Could someone help me out with the code for adding a new event to a specified calendar? I can probably reverse engineer it from there to understand how to work with it.
Thanks
UPDATE
Here is the code I am trying..
// -- perform adding to iCal
// -- select "Test" calendar
theCalendar = iCal.calendars.Test;
events = theCalendar.events;
// -- load in the events
stringifiedData = Safari.doJavaScript("localStorage.getItem('theEvents');", {
in: Safari.windows[0].tabs[0]})
// -- parse data back to js object
theEvents = JSON.parse(stringifiedData);
// -- loop through events
for (var key in theEvents) {
var obj = theEvents[key];
// -- set vars
theDate = obj['date'];
theDescription = obj['description'];
theSummary = obj['summary'];
theLocation = obj['location'];
theStartTime = theDate + " " + obj['startTime'];
theEndTime = theDate + " " + obj['endTime'];
// -- create event object
theEvent = iCal.Event({
description: theDescription,
summary: theSummary,
location: theLocation,
startDate: theStartTime,
endDate: theEndTime
});
// -- get the last index event
last = events.length;
// -- insert it into iCal
events.push(theEvent);
}
The error i'm receiving..
Error on line 68: TypeError: undefined is not an object (evaluating 'events.push(theEvent)')
UPDATE
I figured out the issue. I was formatting the dates incorrectly.. they were just strings. So I made sure to turn them into date objects, and I was able to insert successfully using
events[last] = theEvent;

Pushing Offline Leads using Adwords API

I am using the below function to push my offline leads to api, everything looks good and returns success but when I check adwords, it doesnt show any data saying it received. I have tried many leads and also waited for around 3-4 days now.
What am I doing wrong?
function UploadOfflineConversionsExample(AdWordsUser $user, $conversionName,$gClId, $conversionTime, $conversionValue)
{
// Get the services, which loads the required classes.
// $conversionTrackerService = $user->GetService('ConversionTrackerService', ADWORDS_VERSION);
$offlineConversionService = $user->GetService('OfflineConversionFeedService', ADWORDS_VERSION);
// Associate offline conversions with the upload conversion we created.
$feed = new OfflineConversionFeed();
$feed->conversionName = $conversionName;
$feed->conversionTime = $conversionTime;
$feed->conversionValue = $conversionValue;
$feed->googleClickId = $gClId;
$offlineConversionOperation = new OfflineConversionFeedOperation();
$offlineConversionOperation->operator = 'ADD';
$offlineConversionOperation->operand = $feed;
$offlineConversionOperations = array($offlineConversionOperation);
$result = $offlineConversionService->mutate($offlineConversionOperations);
$feed = $result->value[0];
return ("Uploaded offline conversion value of ". $feed->conversionValue.
" for Google Click ID = ". $feed->googleClickId." and Conversion Name " . $feed->conversionName);
}
In adwords reports this conversion will be shown in Conversions Column. and change the daterange to the date what you pushed as $conversionTime

EWS. How to change DateTimeCreate property via EWS Proxy Classes

I write client application that uses Exchange Web Services Proxy Classes in order to connect to Exchange Web Services. Sometimes, I need create ItemType object and make it looks like as received letter. Therefore I need set up such properties of ItemType as DateTimeSent, DateTimeCreate, DateTimeReceived, but they haven’t public set assessTherefore I need set up such properties of ItemType as DateTimeSent, DateTimeCreate, DateTimeReceived, but they haven’t public set assessor.
I found resolve for some of them via MAPI properties:
ItemType newItem = xmlParser.LoadItem(); //info for newItem takes from xml
newItem.ExtendedProperty = new ExtendedPropertyType[1];
PathToExtendedFieldType q = new PathToExtendedFieldType();
q.PropertyTag = "3590"; //DeliveryTime
q.PropertyType = MapiPropertyTypeType.SystemTime;
newItem.ExtendedProperty[0] = new ExtendedPropertyType();
newItem.ExtendedProperty[0].ExtendedFieldURI = q;
newItem.ExtendedProperty[0].Item = new System.DateTime(2014, 5, 5, 5, 5, 5).ToString("yyyy-MM-ddTHH:mm:ssZ");
Well, it works for DateTimeSent and DateTimeReceived, but not for DateTimeCreate. ES dont give any errors, but DateTimeCreate doesnt change. I tried to UpdateItem with DateTimeCreate propery, but there was no result (update another properties runs fine).
P.S. MAPI ID for CreationTime: 0x3007.
Can someone help me with this problem?
I finally found a solution for this.
Source: https://social.msdn.microsoft.com/Forums/en-US/40a29c69-96d3-488b-8f0e-911dd5f04086/setting-a-emailmessage-datetimesent-and-isdraft?forum=exchangesvrdevelopment
You have to set 3 Extended MAPI properties PR_MESSAGE_FLAGS, PR_MESSAGE_DELIVERY_TIME, and PR_CLIENT_SUBMIT_TIME. Make sure when setting the Time you use UTC time.
For example:
EmailMessage emUploadEmail = new EmailMessage(service);
emUploadEmail.MimeContent = new MimeContent("us-ascii", bdBinaryData1);
// PR_CLIENT_SUBMIT_TIME
emUploadEmail.SetExtendedProperty(new ExtendedPropertyDefinition(57,MapiPropertyType.SystemTime), DateTime.Now.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ"));
// PR_MESSAGE_DELIVERY_TIME
emUploadEmail.SetExtendedProperty(new ExtendedPropertyDefinition(3590, MapiPropertyType.SystemTime), DateTime.Now.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ"));
// PR_MESSAGE_FLAGS
emUploadEmail.SetExtendedProperty(new ExtendedPropertyDefinition(3591,MapiPropertyType.Integer),"1");
emUploadEmail.Save(WellKnownFolderName.Inbox);
Create and last modified dates are read-only and cannot be set. The store provider updates these properties internally.

Using ExchangeService to Add Appointment Occurances

The target is someone's Exchange Calendar (2007). I want to add a simple "Appointment Occurance" to someone's calendar. This code works (I am using the Microsoft.Exchange.WebServices.dll):
service = new ExchangeService(ExchangeVersion.Exchange2007_SP1);
service.Credentials = new NetworkCredential("supervisor", "password", "DOMAIN.COM");
service.AutodiscoverUrl("<employee#domain.com>", ValidateRedirectionUrlCallback);
appt = new Appointment(service);
appt.Subject = "<subject>";
appt.Body = "<Body Text>";
appt.Start = _DateFrom;
appt.End = _DateTo;
appt.Sensitivity = Sensitivity.Private;
appt.Save(WellKnownFolderName.Calendar);
However, there are problems with this code:
The appointment target is the employee. When adding the appointment, the appointment shows up for the employee (yay!) but also for the supervisor (boo!). Am I supposed to use the employee's credentials? If so, what if I do not have access to that - only the supervisors, am I out of the game already?
The appointment shows up in Outlook as a "Meeting Appointment" and not and "Appointment Occurrence". So, the box to input meeting attendees is showing (with no one in it of course), and is irrelevant in my scenario.
appt.Body does not respond at all to Environment.NewLine or "\r\n" - I haven't tried HTML yet.
Instead of WellKnownFolderName.Calendar
You should use new FolderId(WellKnownFolderName.Calendar,"employee#domain.com")
So the last line becomes
appt.Save(new FolderId(WellKnownFolderName.Calendar,"employee#domain.com"));
Also having problems with the newline, this is only since version 1.1 so it probebly is a bug

Resources