• Shiva Prasad Achukatla 22
  • NEWBIE
  • 0 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 1
    Replies
Hi, 

I want to loop through apex map in Javascript. 

My map is like below 
Map<string,list<wrapperObject>> Map_Of_AnswerGroup_childQuestionsGroup = new Map<string,list<warpperObject>>(); 
public String Map_Of_AnswerGroup_childQuestionsGroup_JSON {get;set;}

consrtuctor(){
     if(!this.Map_Of_AnswerGroup_childQuestionsGroup.isEmpty())
            {
                system.debug('debug at 534'+this.Map_Of_AnswerGroup_childQuestionsGroup);
                Map_Of_AnswerGroup_childQuestionsGroup_JSON = JSON.serialize(this.Map_Of_AnswerGroup_childQuestionsGroup.isEmpty());
            }
}

'Map_Of_AnswerGroup_childQuestionsGroup_JSON ' is retruning false after serlization. 

Could someone help me around this. 

The main purpose of this is to be able to loop through map elements in javascript and form dynamic mark up. 



 
Hi,

I have class for which I am facing small issue to cover my test class:

             //My controller class where I am creating ContentDocumntLink

             ContentDocumentLink newFileShare = new ContentDocumentLink();
                newFileShare.ContentDocumentId = listsfa[0].Secured_Files__r.Content_Document_Id__c;
                newFileShare.LinkedEntityId = fileSt.User__c;
                if(fileSt.Requested_Access_Type__c == 'Read')
                     newFileShare.ShareType= 'V';
                else if(fileSt.Requested_Access_Type__c == 'Read/Write')
                    newFileShare.ShareType= 'C';
                listContentShares.add(newFileShare);
                insert listContentShares;


   ***************************************************************************************  

   //TEST CLASS Coverage code

        string before = 'Testing base 64 encode';            
         Blob beforeblob = Blob.valueOf(before);
         //Insert contentdocument data
         ContentVersion cv = new ContentVersion();
         cv.title = 'test content trigger';      
         cv.PathOnClient ='test';           
         cv.VersionData =beforeblob;          
         insert cv;         
                                                
         ContentVersion testContent = [SELECT id, ContentDocumentId FROM ContentVersion where Id = :cv.Id];

        ContentDocumentLink newFileShare = new ContentDocumentLink();
        newFileShare.contentdocumentid = testcontent.contentdocumentid;
        newFileShare.LinkedEntityId = fileSt.User__c;
        newFileShare.ShareType= 'V';
        insert newFileShare;


     In the first attemp I tried with the above SQL query and I m getting below error:

     System.DmlException: Insert failed. First exception on row 0; first error: FIELD_INTEGRITY_EXCEPTION, You cannot create a link for a document in a personal library: [ContentDocumentId]

 
To resolve the above error: I have come up with solution ,

       ContentWorkspace testWorkspace = [SELECT Id FROM ContentWorkspace limit 1];
         ContentWorkspaceDoc newWorkspaceDoc =new ContentWorkspaceDoc();
         newWorkspaceDoc.ContentWorkspaceId = testWorkspace.Id;
         newWorkspaceDoc.ContentDocumentId = testContent.ContentDocumentId;
         insert newWorkspaceDoc;

  It's throwing error:
   System.DmlException: Insert failed. First exception on row 0; first error: INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY, You do not have the level of access necessary to perform the operation you requested. Please contact the owner of the record or your administrator if access is necessary.: [ContentWorkspaceId]



Please help!!