I'm currently trying to create ContentVersion records from Attachment ones but it's giving me the following error:  INVALID_STATUS, Documents in a user's private library must always be owned by that user.: [OwnerId]  Code:  List&lt;Attachment&gt; attLIST = [SELECT Id, Name, Body, BodyLength, ContentType, Description, OwnerId, ParentId, IsPartnerShared FROM Attachment WHERE ParentId = :currentParentID LIMIT 1]; ContentVersion cv =  new ContentVersion(     Title = attLIST[0].Name.substringBefore('.'),     PathOnClient = attLIST[0].Name,     VersionData = attLIST[0].Body,     IsMajorVersion = true,     OwnerId = attLIST[0].OwnerId,     ContentLocation = 'S',     SharingOption = attLIST[0].IsPartnerShared ? 'A' : 'R',     FirstPublishLocationId = attLIST[0].OwnerId ); insert cv; List&lt;ContentDocument&gt; cdLIST = [SELECT Id, Title, LatestPublishedVersionId, FileType, ContentSize FROM ContentDocument ORDER BY CreatedDate DESC]; ContentDocumentLink cdl = new ContentDocumentLink(LinkedEntityId = attLIST[0].ParentId,                                                   ContentDocumentId = cdLIST[0].Id,                                                   ShareType = 'V'); insert cdl;   What am I doing wrong?
123171
I am getting an attachment via a Salesforce email service and in the Email service apex class logic, I query the user object by the email from address and set the ContentVersion owner as the user coming from the Query.  I am getting this error while performing this operation.  INVALID_STATUS, Documents in a user's private library must always be owned by that user.: [OwnerId]  Here is my code :  global Messaging.InboundEmailResult handleInboundEmail(Messaging.InboundEmail email, Messaging.InboundEnvelope envelope) {          Messaging.InboundEmailResult result = new Messaging.InboundEmailresult();          //Get users for the incoming email address and also community user         List&lt;User&gt; lstUsersFromCommunity = [SELECT Id                                              FROM User                                              WHERE Profile.UserLicense.Name = 'Partner Community';                                             AND Email =: email.fromAddress];          //Process only if the incoming email address is belongs to a valid community user         if(lstUsersFromCommunity.size() &gt; 0){             //Get the user from the results list             User user = lstUsersFromCommunity.get(0);             try{                 //Create a list of ContentVersion to store new ContentVersion records                 List&lt;ContentVersion&gt; lstVersion = new List&lt;ContentVersion&gt;();                  //Iterate over the incoming email attachments                 for (Messaging.Inboundemail.BinaryAttachment binaryAttachment : email.binaryAttachments) {                     //New ContentVersion record                     ContentVersion newContentVersion = new ContentVersion();                     newContentVersion.versionData = binaryAttachment.body;                     newContentVersion.OwnerId = user.Id;                     newContentVersion.ContentLocation = 'S';                     newContentVersion.SharingOption = 'A';                     newContentVersion.Origin = 'H';                     newContentVersion.title = email.subject;                     newContentVersion.pathOnClient = binaryAttachment.fileName;                     lstVersion.Add(newContentVersion);                 }                 insert lstVersion;             }catch(Exception ex){                 System.debug('### EXCEPTION :  ' + ex.getLineNumber() + ' : ' + ex.getMessage());             }         }else{             //No user in for the from email address         }          return result;     }
107431
I have a requirement to read and display the owner of a file (for audit purposes), and potentially changing it as well (this is secondary requirement). Are there any nice C# wrappers?  After a quick google, I found only  and a suggestion to PInvoke GetSecurityInfo
387
Hey everyone I've been seeing this a lot lately and am trying to figure out why this error is thrown when querying the SOAP API directly. I've tried several very basic SOQL queries such as  SELECT Body FROM AssetFeed   Only to be met with the sObject type 'AssetFeed' is not supported. error.  The account that I'm currently querying is just a standard user who accepted permission from an app that was created by a Developer Account, so I'm wondering if it might be permissions from the user or permission from the app itself? Possibly because Developer accounts cannot use 95% of whats offered?  The WSDL used is a v27.0 generated Partner WSDL if that helps narrow it down.  I've noticed this in multiple standard objects, so I'm wondering what the trend really is? Seems like a good informational question for future googling of others?  Running describeGlobal()  Array (     [0] =&gt; AggregateResult     [1] =&gt; Attachment     [2] =&gt; ChatterActivity     [3] =&gt; CollaborationGroup     [4] =&gt; CollaborationGroupFeed     [5] =&gt; CollaborationGroupMember     [6] =&gt; CollaborationGroupMemberRequest     [7] =&gt; CollaborationInvitation     [8] =&gt; ContentDocument     [9] =&gt; ContentDocumentFeed     [10] =&gt; ContentDocumentHistory     [11] =&gt; ContentDocumentLink     [12] =&gt; ContentVersion     [13] =&gt; ContentVersionHistory     [14] =&gt; EntitySubscription     [15] =&gt; FeedComment     [16] =&gt; FeedItem     [17] =&gt; FeedLike     [18] =&gt; FeedTrackedChange     [19] =&gt; Group     [20] =&gt; GroupMember     [21] =&gt; HashtagDefinition     [22] =&gt; Name     [23] =&gt; TaskPriority     [24] =&gt; TaskStatus     [25] =&gt; User     [26] =&gt; UserFeed     [27] =&gt; UserPreference     [28] =&gt; UserRecordAccess     [29] =&gt; UserRole )   Where would all the rest of my SOAP SObjects be? This seems like a very thin list compared to the 295 SObjects advertised
73714
How do I use the Tooling API to create a new Apex Trigger (rather than update an existing one)?  According to the  I need to specify the ContentEntityId as an existing Trigger Id. But in my case I don't have an Id because I've trying to create a new sObject.  If I omit the ContentEntityId I get an error back in the SaveResult:     Status Code: INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY   Message: "insufficient access rights on cross-reference id"   The following is more or less a test case in C# that attempts to use the SOAP tooling API to create the new trigger.  SforceService toolingService = //... Get instance of the Tooling API  MetadataContainer container = new MetadataContainer(); container.Name = "Test" + DateTime.Now.Ticks;  SaveResult[] saveResult = toolingService.create(new sObject[] { container }); string metaDataContainerId = saveResult[0].id;  ApexTriggerMember apexTriggerMember = new ApexTriggerMember(); apexTriggerMember.MetadataContainerId = metaDataContainerId; apexTriggerMember.Body = "trigger TestOpportunityBeforeUpdate on Opportunity (before update) {\n//Horray\n}";     // Adding this will successfuly update the existing trigger //apexTriggerMember.ContentEntityId = "01q70000000GuzP";  SaveResult[] triggerSaveResults = toolingService.create(new sObject[] { apexTriggerMember }); Assert.AreEqual(1, triggerSaveResults.Length); SaveResult triggerSaveResult = triggerSaveResults[0]; if (!triggerSaveResult.success) {     Assert.Fail(triggerSaveResult.errors[0].message); } Assert.IsTrue(triggerSaveResult.success);  ContainerAsyncRequest containerRequest = new ContainerAsyncRequest(); containerRequest.MetadataContainerId = metaDataContainerId; containerRequest.IsCheckOnly = false;  SaveResult[] containerResults = toolingService.create(new sObject[] { containerRequest });
2033
I am working on a third party database.  When I try to view the definition of a view by right clicking, CREATE TO and then to NEW QUERY EDIT WINDOW, I am getting an error:     This property may not exist for this object or may not be retrievable   due to insufficient access rights. The text is encrypted.
87644
I have created the "Gallery" content type, and added two fields: "photo," and "document." I then used the following code for uploading a file in the "document" field:  $file = file_save_upload('document', array(     'file_validate_extensions' =&gt; array('txt doc'), // Validate extensions. ));  // If the file passed validation: if ($file) { // Move the file, into the Drupal file system if ($file = file_move($file, 'public://')) {   $file-&gt;status = FILE_STATUS_PERMANENT;  // $file-&gt;file_display = 1;   $file = file_save($file);  } else {   $output = t('Failed to write the uploaded file the site\'s file folder.'); }         } else { $output = t('No file was uploaded.');  }   I am attaching this file to the node using the following code:  $customNode-&gt;field_document[$customNode-&gt;language][0] = (array)$file;   When I call node_submit() function, I get the following error:     Integrity constraint violation: 1048 Column 'field_document_display' cannot be null    Does anybody know what I am doing wrong?
18864
Is there any way other than looping through the Files to check whether the folder or files exist in document library using clientcontext - client object model..  Can someone confirm me whether the below code will work or not. Or will it create any exception??  using(var clientContext = new ClientContext(site))  {  Web web = clientContext.Web;  Microsoft.SharePoint.Client.File file = web.GetFileByServerRelativeUrl("/site/doclib/folder/filename.ext");  bool bExists = false;  try { clientContext.Load(file);  clientContext.ExecuteQuery();   bExists = file.Exists;  } catch{ }  if (bExists ) { . .  }
48651
I downloaded a file from the internet (I can link to it here, but in the interests of not annoying other users, I won't post the link), and I can't delete the file with the message:   You need permission to perform this action  You require permission from the computer's administrator to make changes to this file   Trouble is, I am the administrator and UAC is completely off.  If I go into the Properties/Security tab, I get the message   You do not have permission to view or edit this object's permission settings   Clicking "Advanced"/Owner, it says:   Current owner: Unable to display current owner.   If i try to change the owner, I get the same message:   Unable to set new owner on file  Access is denied.
104197
When i create new User Account and login with that credentials, it gives me this problem if admin doesnt have set thier values yet !!!**  AllotmentList = [select id, Days_Remaining__c from PTO_Allotment__c where Year__c =:year and Employee__c=:EmployeeList[0].id LIMIT 100]; //access only Current user Allotment details                 //to handle Listoutof Bound Exception wrote if-else          if(AllotmentList.size()&gt;0)         {         requests.PTO_Allotment__c=AllotmentList[0].id;         requests.Days_Remaining__c=AllotmentList[0].Days_Remaining__c;         }         else         {             //write a code when AllotmentList is empty ....         }
64657
I've a object called myobject__c. This object is private in OWD Setting.  Now when admin create a new record of this object then I want to share this record with a user(community user). For this I've written a code in trigger to create a sharing record of this object (myobject__Share).  But I am getting a problem of :-      FIELD_INTEGRITY_EXCEPTION: field integrity exception: unknown (invalid   user or group: 005XXXXXXXXXXXXX).   how can I solve this problem and second doubt is can we create share record for community user or not.
66794
I tried to publish some content types inside my site collection hub, but the content types were not published correctly, as they did not appear under custom content types at the other site collections. now i checked Content Type Subscriber status and it showed its last run =N/A as follow:-    Now i checked the "Content type publishing error log" under the site collection hub , but it did not show any errors .  and when i checked the Content Type hub job , i find that the web application is set to N/A, as follow, although the managed metadata is connected to the web application :-    so can anyone advice how i can fix this problem ?
19790
Please Help me...  Account sObject is Parent of Attachment. Now I want to bring Read-only Field Custom field (isReadOnly__c).  SELECT Id, Name, Account.isReadOnly__c FROM Attachment   How It Gets ?  Thanks in Advance  Manu
113132
I have noticed that I am unable to preserve ownership if I rsync -o files. However, I am when I move them.  This is all without admin privileges. What is the rationale of this? Several threads e.g. () seem to echo the need for admin privileges
93329
i am trying to update a listitem in a event receiver on FeatureActivated in a document library.   public override void FeatureActivated(SPFeatureReceiverProperties properties)     {          SPSecurity.RunWithElevatedPrivileges(delegate()         {             using (SPSite site = SPContext.Current.Site)             {                 using (SPWeb myweb = site.OpenWeb())                 {                   SPList list = myweb.Lists.TryGetList("Document Library");                 SPListItemCollection items = list.GetItems();                  for (int i = 0; i &lt; items.Count; i++)                 {                      SPListItem item = items[i];                        Guid fieldID = item.Fields.GetFieldByInternalName("Age").Id;                      string valueField = item[fieldID].ToString();                     valueField = "";                     item.Update();                 }                 }             }         });                 }   My field does not get empty?
21759
I have a Visualforce page that renders perfectly as a PDF that I'd like to attach to an opportunity record and to attach to an email.  Whenever the code gets to getContent(), I keep getting an error saying      Too many nested getContent calls   Below, you can see the code is very simple.  Just pulls data to fit into the VF page in the substitution blanks then tries to create the PDF.  Looking at the debug log, the call to getContent() only happens once.  I'm stumped!  Thanks for your ideas...  public with sharing class GenerateThankYouLetterAsPDF {   // a handful of fields that are {!field} substitutions on the VF page     public id oppID {get; set;}     public string giftAmount {set; get;}     public string giftDate {set; get;}     //  etc...       public GenerateThankYouLetterAsPDF() {         id oppID = id.valueof( ApexPages.currentPage().getParameters().get('id') );               // set the values of field substituions           string filename = 'donation.pdf';          // Generate the PDF          PageReference pdf = ApexPages.currentPage();         system.debug ('calling getContent...');         blob b = pdf.getContent();   }                 }
75615
In order to create record in bulk using REST API, we using Composite Tree resource.  I'm trying to upload a bulk of content versions :   {"records" :[  {   "attributes" : {"type" : "ContentVersion", "referenceId" : "ref1"},   "VersionData":"/9j/4AAQSkZJRgABAQEAYABADn/2Q==",   "PathOnClient":"Array1.jpg",   "Description":"Array1"  },   {   "attributes" : {"type" : "ContentVersion", "referenceId" : "ref2"},   "VersionData":"/9j/4AAQSkZJRgh25==",   "PathOnClient":"Array2.jpg",   "Description":"ARRAy2"  } ] }   Using endpoint: .  My questions are:   The Response when everything handled fine is :      {     "hasErrors": false,     "results": [         {             "referenceId": "ref1",             "id": "0680Q0000006OSwQAM"         },         {             "referenceId": "ref2",             "id": "0680Q0000006OSxQAM"         }     ] }    But in Case we have one error on one of the files - I'm getting the next response:  "results": [         {             "referenceId": "ref2",             "errors": [                 {                     "statusCode": "SOME ERROR",                     "message": "SOME ERROR",                     "fields": [                         "SOME FIELD THAT GET THE ERROR"                     ]                 } ]   BUT what happened to the other files that actually succeeded?  If there is one error on one of the files, Does it make it all fail? Even if they were succeeded?  If it does, Is there another method that I can upload a bulk of Content Version using REST API?  2.What about the size limit of Content Version in MB that I can upload with this approach? What is the max size that this API can handle with? I made a test and I succeed to upload files with a sum of 16 MB via this API - But I couldn't create a blob version more than this - It just caused my computer to stop working
85919
While cloning record i am getting the below error in the 1st line of the code, the SOQL. Can anyone help me with that.  XX_Segment__c desc1 = [select  Id, XXX_New_Keyword_Description__r.Description__c from XX_Segment__c where Availability_Forecast_XXX__c =:id1]; String s= desc1.XXX_New_Keyword_Description__r.Description__c; s= s.substring(0,3); String s1 = s+'%';   Regards