Loading
Assicurazioni
Come inserire le note nelle tempistiche della cronologia richieste

Come inserire le note nelle tempistiche della cronologia richieste

Aggiungere e distribuire una classe Apex denominata GetContentNoteAsStory da utilizzare con l'impostazione di configurazione dell'oggetto storia Claim_ContentNote.

  1. Abilitare le note. Da Imposta, nella casella Ricerca veloce, immettere Impostazioni note e quindi selezionare Impostazioni note. Verificare che sia selezionata l'opzione Abilita note.
  2. Fare clic sul menu di accesso rapido (Icona ingranaggio) e selezionare Developer Console.
  3. Fare clic su File | Nuovo | Classe Apex.
  4. Immettere GetContentNoteAsStory come nome della classe Apex e quindi aggiungere questo codice. Salvare la nuova classe Apex.
    global with sharing class GetContentNoteAsStory implements VlocityOpenInterface2
    {
        global Object invokeMethod(String methodName,Map<String,Object> inputs, Map<String,Object> output, Map<String,Object> options)
        {
            Boolean success = true;
            try
            {
                if(methodName == 'getContentNotes')
                {
                    success = getContentNotes(inputs, output, options);
                }
            }
            catch (Exception e)
            {
                System.debug('Error invoke method: ' + methodName + ' with error: '+ e);
                success = false;
                throw e;
            }
            return success;
        }
    
        private Boolean getContentNotes(Map<String,Object> input, Map<String,Object> output, Map<String,Object> options)
        {
            String parentObjName = (String) input.get('parentObjName');
            String objName = (String) input.get('storyObjType');
            List<Object> objIdList1 = (List<Object>) input.get('objIds');
            List<Id> objIdList = new List<Id>();
            integer queryRecordLimit = (integer) input.get('pageSize');
            DateTime lastDate = (DateTime) input.get('lastActivityDate');
            List<Object> listOfStories = new List<Object>();
    
            if (queryRecordLimit == null) queryRecordLimit = 10;
    
            for (Object objId : objIdList1) objIdList.add((Id) objId);
    
            //query for content note for parentObject
            List<ContentDocumentLink> docLinks = [
                SELECT ContentDocumentId, Id, LinkedEntityId
                FROM ContentDocumentLink
                WHERE LinkedEntityId IN :objIdList
            ];
            // ShareType, SystemModstamp, Visibility
    
            List<Id> docIdList= new List<Id>();
            Map<Id, Id> objIdContentDocIdMap = new Map<Id, Id>();
            if (docLinks != null && docLinks.size() > 0)
            {
                for (ContentDocumentLink docLink :docLinks )
                {
                    docIdList.add(docLink.ContentDocumentId);
                    objIdContentDocIdMap.put(docLink.ContentDocumentId, docLink.LinkedEntityId);
                }
    
                List<String> fields = new List<String>
                {
                    'Id',
                    'FileExtension',
                    'FileType',
                    'Title',
                    'Content',
                    'TextPreview',
                    'LastModifiedBy.Name',
                    'LastModifiedDate',
                    'CreatedById',
                    'CreatedBy.Name',
                    'CreatedBy.Title',
                    'OwnerId',
                    'Owner.Name',
                    'Owner.Title'
                };
    
                String objQuery = 'SELECT ' + String.join(fields, ', ') + ' ';
                objQuery += 'FROM ContentNote ';
                objQuery += 'WHERE Id IN :docIdList ';
                objQuery += 'AND LastModifiedDate != null ';
                if (lastDate != null)
                {
                    objQuery += ' AND LastModifiedDate <= :lastDate ';
                }
                objQuery += ' LIMIT '+String.valueOf(queryRecordLimit);
    
                List<ContentNote> listContentNote = Database.query(objQuery);
    
                for (ContentNote cnote : listContentNote)
                {
                    Map<String, Object> resultMap = new Map<String, Object>();
                    DateTime LastActDate = cnote.LastModifiedDate;
    
                    Map<String, String> summaryLabelMap = new Map<String, String>();
                    summaryLabelMap.put('Title', 'Title');
                    summaryLabelMap.put('Subtitle', 'Content');
    
                    Map<String, String> summaryValueMap = new Map<String, String>();
                    summaryValueMap.put('Title', cnote.Title);
                    summaryValueMap.put('Subtitle', cnote.Content.toString());
    
                    Map<String, String> detailMap = new Map<String, String> ();
                    String ownerValId = String.valueOf(cnote.OwnerId);
                    User owner = cnote.Owner;
                    Map<String, Object> ownersMap = new Map<String, Object>
                    {
                        'ID' => cnote.OwnerId,
                        'Owner' => owner.Name,
                        'Title' => owner.Title
                    };
    
                    Boolean isDate = false;
                    String idValue = String.valueOf(cnote.Id);
                    String lastModify = (String) cnote.getSObject('LastModifiedBy').get('Name');
                    String image;
                    String parentRecId = objIdContentDocIdMap.get(cnote.Id);
                    String parentRecName;
                    String navPath;
                    String objDef = 'ContentNote';
                    String parObjType=parentObjName;
                    String ownerId = cnote.LastModifiedBy.Id;
    
                    resultMap.put('lastActDate', LastActDate);
                    resultMap.put('summaryLabelMap', summaryLabelMap);
                    resultMap.put('summaryValueMap', summaryValueMap);
                    resultMap.put('detailValueMap', detailMap);
                    resultMap.put('IdValue', idValue);
                    resultMap.put('imageRef', image);
                    resultMap.put('sortFieldIsDate', isDate);
                    resultMap.put('parentId',parentRecId);
                    resultMap.put('parentName', parentRecName);
                    resultMap.put('navigateLink', navPath);
                    resultMap.put('objAPIName', objDef);
                    resultMap.put('parentObjAPIName', parObjType);
                    resultMap.put('owner', cnote.LastModifiedBy.Id);
                    resultMap.put('modified', lastModify);
                    resultMap.put('ownerValueMap', ownersMap);
                    listOfStories.add(resultMap);
                }
            }
    
            if (listOfStories != null && listOfStories.size() > 0)
            {
    
                output.put('stories', listOfStories);
            }
            return true;
        }
    }
    
  5. Da Imposta, nella casella Ricerca veloce, immettere Impostazioni personalizzate e selezionare Impostazioni personalizzate.
  6. Individuare Configurazione oggetto storia e fare clic su Gestisci.
  7. Nell'impostazione dell'oggetto storia Claim_ContentNote, immettere Rivendicazione come Nome oggetto controllante.
 
Caricamento
Salesforce Help | Article