• sfdcdude
  • NEWBIE
  • 10 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 10
    Questions
  • 14
    Replies
Hi Team,
Can anybody help me for the test class for teh below logic?

public without sharing class fileattachment {
    public User usr{get;set;}  
    
    public transient String base64{get;set;}
      public String fileName {get; set;}
    
    public fileattachment() {        
        Id userId = apexpages.currentpage().getparameters().get('id');
        usr = [SELECT Id,ContactId,MemberCardDownloadLink__c,MemberCardPreviewLink__c from User where Id=:userId];
    }
    
    public void savefile() {
        
        //Delete older Cards
        List<ContentDocument> docDeleteList = new List<ContentDocument>();
        for(ContentDocumentLink cdl : [select Id, ContentDocumentId 
                                       FROM ContentDocumentLink 
                                       WHERE LinkedEntityId =:usr.ContactId
                                       AND (ContentDocument.Title ='test.png' OR 
                                            ContentDocument.Title ='test1.png')]) 
        {
            docDeleteList.add(new ContentDocument(Id=cdl.ContentDocumentId));                            
        }
        if(!docDeleteList.isEmpty()) {
            delete docDeleteList;
        }
        
        //Insert Doc
        ContentVersion testContentInsert = new ContentVersion();
        testContentInsert.Title = filename;
        testContentInsert.VersionData = EncodingUtil.base64decode(base64);
        testContentInsert.PathOnClient = filename ;
        insert testContentInsert;
        
        List<ContentVersion> cvList = [select id, ContentDocumentId from ContentVersion WHERE Id =:testContentInsert.Id];
        
        ContentDocumentLink cl = new ContentDocumentLink();
        cl.ContentDocumentId = cvList[0].ContentDocumentId;
        cl.LinkedEntityId = usr.ContactId;
        cl.ShareType = 'V';
        cl.Visibility = 'AllUsers';        
        insert cl;        
        
        //Make it public
        ContentDistribution newDist = new ContentDistribution();
        newDist.ContentVersionId = cvList[0].Id;
        newDist.Name = 'External Link';
        newDist.PreferencesNotifyOnVisit = false;
        newDist.PreferencesAllowViewInBrowser = true;
        newDist.PreferencesAllowOriginalDownload=true;
        newDist.PreferencesAllowPDFDownload=true;
        insert newDist;
        
        //Store the link on User Record
        for(ContentDistribution distribution : [Select Id,ContentDownloadUrl,DistributionPublicUrl 
                                                FROM ContentDistribution 
                                                WHERE Id =: newDist.Id])
        {
            usr.MemberCardPreviewLink__c = distribution.DistributionPublicUrl;
            usr.MemberCardDownloadLink__c = distribution.ContentDownloadUrl;
        }
        update usr;
        
    }  
}
Hi Team,

I have a report requirement below. Can any one provide solution how to achieve this?

Req: Lets say i have 10 opportunities in "Identified" stage and another 10 in "Inqualified" stage and these 20 opportunities are in previous quarter.
In report, i need to show the data like..... how many opportunities are moved from Identified to In qualified from previous quarter to current quarter and in the current quarter && in identified stage opportunities, how much amount is increased and how much amount is decreased.

If i have this report in handy i need to show them in a stacked bar chart of dashboard.

Please let me know if this requirement is not clear.
Thanks.
Hi Team,

I would like to show the custom add error message when certain profile users tries to upload the files. But it is showing the standard "Cant add 1 file for Upload" mesage. 

Do we have any wokraround for this?

Thanks,
Pradeep. P
Hi Team,

I am not able to make the required checkbox to true for one lookup filed. Please see below. When I click on edit for this field. I am not able to see the option either. Please suggest.

User-added image
Hi Team,

I have a scenario where, I need to send email alerts after 1 hour and next every one hour continuously till the status will get change from A to B. 

We know that we do not have option to schedule an alert daily by using wrokflow rules. but some workaround (https://salesforce.stackexchange.com/questions/221834/email-alter-to-everyday-using-time-dependent-workflow-action-in-salesforce) I have found and did the same.
It is working upto some extent and my issue here is......

Lets say my 5 records email alert scheduled 5:00 PM after meeting criteria.
When I change any of the record from A to B at 6:00 PM this particular record related alert is going away from the scheduled queue which is expected. But, this record related updated time (6:00 PM) is effecting for the rest of the 4 records too. 

Please help me here to resolve this issue.
Hi Team,

I have a scenario where, I need to send email alerts after 1 hour continuously till the status will get change from A to B. 

We know that we do not have option to schedule an alert daily by using wrokflow rules. but some workaround (https://salesforce.stackexchange.com/questions/221834/email-alter-to-everyday-using-time-dependent-workflow-action-in-salesforce) I have found and did the same.
It is working upto some extent and my issue here is......

Lets say my 5 records email alert scheduled 5:00 PM after meeting criteria.
When I change any of the record from A to B at 6:00 PM this particular record related alert is going away from the scheduled queue which is expected. But, this record related updated time (6:00 PM) is effecting for the rest of the 4 records too. 

Please help me here to resolve this issue.
Hi Team,

I have added notes and attachments to custom object__c. when user deletes a file from content document object or content document link object, I need to throw an error to user. Please post code if you have handy.

Thanks.
Hi Team,

How can we hide the below options for a user.? Please suggest.

User-added imageThanks,
Pradeep
 
Hi Team,

How can we hide the below options for a user.? Please suggest.
User-added image



Thanks,
Pradeep.p
If user enters a Weekend (Saturday, or sunday) date in field A, I would like to see the fridays date in B field. And My field A datatype is datetime not Date. Please guide me or post your answer please. Thank you.
 
Hi Team,

I would like to show the custom add error message when certain profile users tries to upload the files. But it is showing the standard "Cant add 1 file for Upload" mesage. 

Do we have any wokraround for this?

Thanks,
Pradeep. P
Hi Team,

I am not able to make the required checkbox to true for one lookup filed. Please see below. When I click on edit for this field. I am not able to see the option either. Please suggest.

User-added image
Hi Team,

I have a scenario where, I need to send email alerts after 1 hour and next every one hour continuously till the status will get change from A to B. 

We know that we do not have option to schedule an alert daily by using wrokflow rules. but some workaround (https://salesforce.stackexchange.com/questions/221834/email-alter-to-everyday-using-time-dependent-workflow-action-in-salesforce) I have found and did the same.
It is working upto some extent and my issue here is......

Lets say my 5 records email alert scheduled 5:00 PM after meeting criteria.
When I change any of the record from A to B at 6:00 PM this particular record related alert is going away from the scheduled queue which is expected. But, this record related updated time (6:00 PM) is effecting for the rest of the 4 records too. 

Please help me here to resolve this issue.
Hi Team,

I have added notes and attachments to custom object__c. when user deletes a file from content document object or content document link object, I need to throw an error to user. Please post code if you have handy.

Thanks.
Hi Team,

How can we hide the below options for a user.? Please suggest.

User-added imageThanks,
Pradeep
 
Hi Team,

How can we hide the below options for a user.? Please suggest.
User-added image



Thanks,
Pradeep.p
If user enters a Weekend (Saturday, or sunday) date in field A, I would like to see the fridays date in B field. And My field A datatype is datetime not Date. Please guide me or post your answer please. Thank you.
 
In Apex using a AfterInsert Trigger over ContentDocumentLink (cdl) object, the method cdl.addError ('Custom message') is not working as expected. 
According to standard documentation https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_contentdocumentlink.htm using a cdl.addError ('Custom message') should show a custom message error to the user (Standard lightning component Notes)
This is not the case. Instead the error that is showing is just standard error that provide no information to the user.
trigger cdlTrigger on ContentDocumentLink (after insert) {
    for (ContentDocumentLink cdl : trigger.new) {
        if (!CDLHelper.isSharingAllowed(cdl)) {
            cdl.addError('Sorry, you cannot share this file.');
        }
    }
}

public class CDLHelper {
    public static boolean isSharingAllowed(ContentDocumentLink cdl) {
       return false;
    }

}

 
Hello Everyone,

How to exclude Weekends on Workflow Task Due Dates?
On Workflow Tasks, we are setting up a due date extending with 'X' days, here, we need to exclude the weekends.

For Example, if we setup a workflow task to "Rule Triggered Date + 5 Days" and if that 5th day falls on weekend either Saturday or Sunday, SF should automatically consider the next Business Day, i.e Monday.

Different Workflows have different Due Dates, need to work it for all Workflow Tasks (on different Objects), irrespective of Due Date.
And Different Workflows have multiple actions like Email Alert, Field Update and Outbound Messages along with Tasks.

Can any one please help me out on achieving same?

Thanks in Advance,
Ranjith.

For the Note & attchment Related Link, it possiblt to remove Attach File button?

Or have any idea or suggestion not let the user to attach the file?

 Thanks.

 

Best Regrds:

May