Multiple objects with the same name were found - ms-office

I'm working on an App for Office that inserts text/images into specific parts of the current Word document, as far as I've investigated, the only way to achieve this is by using ContentControls and creating a binding with:
Office.context.document.bindings.addFromNamedItemAsync();
Now, the problem is that when I have Content Controls inside both, the document body and the header/footer, I'm getting the following error:
Code: 3007
Name: Binding Creation Error
Message: Multiple objects with the same name were found.
According to Microsoft's website!, this is due to 2 or more CCs with the same name; but this is not the case since every CC that I created has an unique name, and when I move all of them to either the header/footer or the body, it works, the error just happens when they are located in different sections of the document.
This is the code I'm using:
Office.context.document.bindings.addFromNamedItemAsync("HeaderLogoCC","text",
{ id: 'logoBinding' }, function (result)
{
if (result.status == "failed")
{
result.error.message == "The named item does not exist."
}
(I know my English is not the best, I apologize in advance for any mistake and I can try to make it more clear, if necessary).
Any help would be really appreciated,
Thanks!

Related

Netsuite Invalid API usage. You must use getValue to return the value set with setValue

So I have an odd issue, When I create a new transaction and save, this error in the title gets thrown. But when I edit this transaction after it was created, the getText does not throw this error. Is there something I'm doing wrong or something special needed to getText on a create new record? Here is my code. This is for the afterSubmit method on my User Event Script for Vendor Bill screen. I just noticed getValue does work on create, does not produce this error, just don't understand why? Is this the correct way to get the value on create? To use getValue and getText cannot be used on create? Only for edit?
if (scriptContext.type == scriptContext.UserEventType.CREATE ||
scriptContext.type == scriptContext.UserEventType.EDIT) {
// get bill to index
var Bill = scriptContext.newRecord;
// fails on this call below on create but works on edit
var refno = Bill.getText({ fieldId: 'tranid' });
}
This behavior is described in the API documentation here.
In dynamic mode, you can use getText() without limitation but, in standard mode, limitations exist. In standard mode, you can use this method only in the following cases:
You can use getText() on any field where the script has already used setText().
If you are loading or copying a record, you can use getText on any field except those where the script has already changed the value by using setValue().
Apparently the newRecord object falls under the second criteria. At this point, the object only has values set. tranid will have a value with the transaction's internal ID, but it won't have the transaction name stored. To get the text, you will have to use record.load() to get the full record, or use search.lookupFields() to get just the transaction name.

Is there a way to resolve this error: "CloudKit integration requires does not support ordered relationships."

I'm trying to use Apple's CoreDataCloudkitDemo app. I've only changed the app settings per their README document. On running the demo, I'm getting the error: "CloudKit integration requires does not support ordered relationships."
(The weird grammar in the title is included in the app)
The console log shows:
Fatal error: ###persistentContainer: Failed to load persistent stores:Error Domain=NSCocoaErrorDomain Code=134060 "A Core Data error occurred." UserInfo={NSLocalizedFailureReason=CloudKit integration requires does not support ordered relationships. The following relationships are marked ordered:
Post: attachments
There is the same error for the "Tags" entity.
I'm using Xcode 11.0 beta 4 (11M374r).
I've only changed the bundle identifier, and set my Team Id.
I removed the original entitlements file - no errors in resulting build.
I've not changed any code from the original.
Does anyone have a workaround, or preferably, a fix? Or did I do something wrong?
Thanks
Firstly, select CoreDataCloudKitDemo.xcdatamodeld -> Post -> RelationShips, select attachments relationship, on the Inspect panel, deselect Ordered, then do the same thing on the tags relationship.
Secondly, there will be some errors in the code now, because we unchecked the Ordered option, the property of attachments and tags in the generated NSManagedObject may changed from NSOrderedSet? to NSSet?. So we could change these error lines of code like below:
Origin:
guard let tag = post?.tags?.object(at: indexPath.row) as? Tag else { return cell }
Changed:
guard let tag = post?.tags?.allObjects[indexPath.row] as? Tag else { return cell }
Finally, you can run the code now. ;-)
Further more, on WWDC19 Session 202, the demo shows they set both attachments and tags relationships as Unordered, so I think there's something wrong in the given demo project.

Access document when I have the UID

I have a combobox on my form that loads client names from a view using the format "name | UID" - this displays the client name on the form but saves the UID in the field.
I now want to use the UID to lookup the name for the client and save it in a field on the XPage that is not visible using the following code:
// ignore when UID is null
if (getComponent("parentUID").getValue() == null)
return false;
var UID:string = getComponent("parentUID").getValue();
var doc:NotesDocument = database.getDocumentByUNID(UID);
// now set your fields
document1.setValue("nachname", doc.getItemValueString ("nachname"));
document1.setValue("vorname", doc.getItemValueString ("vorname"));
I do this in a simple action attached to a button. The next simple action is a Save.
The code crashes with the following error:
Error while executing JavaScript action expression
Script interpreter error, line=8, col=42: [TypeError] Exception occurred calling method NotesDatabase.getDocumentByUNID(java.lang.String) null
I have copied the parentUID to a field on the document and I am getting the correct UID and the document exists in the database?
Any ideas?
PS: I am adding this to an existing application and the current document is not a response document - cannot change that unfortunately :o(
OK, I have found my problem - XPages returned the UID but it included a leading space. When I concatenated the values I did the following: "name | UID" i.e. I added a leading and trailing space to the pipe symbol to make the code legible - this was causing the problems.
It looks like you are missing the get.Value() in your getComponent line
Try getComponent("parentUID").getValue() == null
My guess is that this is causing the code to run when the UID is null. This means that the code is running when it really is null, and your effort to check for that isn't working.
Thanks for checking that.
Can you put in a print() statement and ensure that you have a value in the var UID.
Another thing, please capitalize the word "String" since java classes are capitalized.

Searching by related model field

I know there are plenty of topics on this but I searched&tried so many and it is still not working.
I have tables: Team and Worker. Any worker can be assigned to a Team. So at the Workers Manager I want to search Workers also by Team name.
I got the column etc. but when I type part of team name - search starts but the written text dissappears and search doesn't care about the field. I checked the AJAX call with Firebug and there is a field called teamName (I added public field to my Worker model class). But when I print_r criteria in my search method - there is no condition.
How is that possible? How can I perform the searching by related field?
EDIT (my serach() method):
public function dsearch()
{
// Warning: Please modify the following code to remove attributes that
// should not be searched.
$criteria=new CDbCriteria;
$criteria->compare('idWorker',$this->idWorker);
$criteria->compare('idLeaderType',$this->idLeaderType);
$criteria->compare('t.idTeam',$this->idTeam);
$criteria->compare('idVoip',$this->idVoip);
$criteria->compare('workLogin',$this->workLogin,true);
$criteria->compare('workPass',$this->workPass,true);
$criteria->compare('name',$this->name,true);
$criteria->compare('surname',$this->surname,true);
$criteria->compare('madeCalls',$this->madeCalls);
$criteria->compare('deleted',$this->deleted);
$criteria->compare('liveChanges',$this->liveChanges);
$criteria->compare('confirmer',$this->confirmer);
$criteria->compare('oldWorkerNum',$this->oldWorkerNum);
$criteria->compare('idDepart',$this->idDepart);
$criteria->compare('Team.name', $this->teamName, true);
$criteria->with=array('Team');
$criteria->together = true;
return new CActiveDataProvider($this, array(
'criteria'=>$criteria,
));
}
Use the mergeWith: Hope it works.
if($merge!==null){
$criteria->mergeWith($merge);
}
Reference:http://www.yiiframework.com/doc/api/1.1/CDbCriteria#mergeWith-detail
I found usefull extension to do that:
http://www.yiiframework.com/extension/relatedsearchbehavior/
I couldnt get it to work somehow. I downloaded new version and now its fine.
It works pretty well. Thanks for your time though.

Unexpected ArgumentExecption when accesing a Field Value in a SPListItem

I have the following helper method that returns the value from a field.
public static string GetValueFrom(SPListItem item, string fieldName)
{
string value = string.Empty;
if (item.Fields.ContainsField(fieldName))
{
SPField field = item.Fields.GetField(fieldName);
if (item[field.InternalName] != null)
{
value = item[field.InternalName].ToString();
}
}
return value;
}
However for one Field (normal Choice Field) I am getting a ArgumentExecption on this line
if (item[field.InternalName] != null)
I am using
SPListItem item = list.GetItemById(itemId);
To get the item.
I cant find why I am getting the exception when I am checking to see if the field exists?
Any ideas as to why I am getting this Exception for only one field.
Update.
When debugging
The call to GetField() returns the correct field object.
Field.InternalName contains the correct Internal name of the field
If I try and access the value using item["internal name of the field"] it still throws and exception for only this one field.
Sometimes strange things happens and we do not have logical answer to those questions. Try by deleting the list and then creating the list again from scratch. DO NOT try to save it as template and DO NOT try to create the list from that template.
One possible reason of such type of ugly messages is that the security/permissions are not allowing to manipulate that field/column.
Another possible reason of such type of unwanted/unexpected messages is that when the field was created for the first time, its data type was different and later on it was changed to choice. Technically there should be no problem in doing so but sometimes we face odd behavior.
Have you tried debugging? Questions you should answer (because we can't):
Is field a valid value, or null, after the call to GetField()?
If field is not null, what does field.InternalName actually return?
If field.InternalName returns a valid value, can you access it by hard-coding that value in the indexer? i.e. item["fieldInternalName"]
Finding that information may help you solve the problem yourself, but if it doesn't add it to your post so the community has a better chance of helping you.
I do experienced this many a times. The reason for this is if you are logged-in as a non Admin Account(System Account) the default List View Lookup Threshold for the User is 8 for the lookup columns. i.e for the default view the user can access upto the 8 lookup fields only. If you change the List Throttling to >8 it will be resolved. But increasing this will degrade the performance.
Go to Central Admin >> Manage Web Applications >> Select the Web Application >> General Settings Dropdown >> Resource Throttling >> Change the "List View Lookup Threshold" to more than 8
Thanks,
-Codename "Santosh"

Resources