• Evan Shuey
  • NEWBIE
  • 15 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 1
    Replies
Hello all, 

I have an interesting project I am working on... I am helping build a AppExchange app and I need to build a feature that allows users of the app to send out a form to their clients. The clients wont always have salesforce. The clients need to be able to add information to the form and upon saving, that information updates related records in the parent companies salesforce org. I was thinking about trying a Force.com site, but I have never tried. Anyone else do something like this? Not looking for someone to write any code, just ideas. 

Thanks all!!
Hello all. I am making a class that ensures that there is an attachment on an Opp whenever its closed won. Below is my class that actually does the logic. Below that is the test class. The logic works fine but I can only get 42% coverage though. The underlined code is what is not being covered, this is in a Lightning instance fyi. Thanks for the help!

public class OpportunityHandler {
    public static void checkOppForAttachment (List<Opportunity> oppList){
        
        for(Opportunity opp : oppList){
            if(opp.stageName == 'Closed Won' || opp.stageName == 'Closed Won (R)'){
                ContentDocumentLink cdl = null;
                List<ContentDocumentLink> cdl2 = [Select Id from ContentDocumentLink where LinkedEntityId =:opp.Id];
                   
                if (cdl2.isEmpty()){

                    opp.addError('Please ensure the contract is attached prior to closing this Opportunity');
                }
            }
        }
    }
}

Test Class
@isTest
public class OpportunityHandlerTest {
    @isTest public static void validateAttachment() {
        //Create Account and Opportunity
    List<RecordType> acctRecType = [Select Id from RecordType where developerName = 'Company' and sObjectType = 'Account'];
    List<RecordType> oppRecType  = [Select Id from RecordType where developerName = 'AM_Channel' and sObjectType = 'Opportunity'];
            Test.startTest();
        try{
    Account acct      = new Account();
    acct.name         = 'Test Account1';
    acct.RecordTypeId = acctRecType.get(0).id;
    insert acct;
        
    Opportunity opp     = new Opportunity();
        opp.Name        = 'test opp';
        opp.CloseDate   = system.today()+1;
        opp.StageName   = 'Initial Pitch/Demo';
        opp.Use_Case__c = 'Brand Tracker';
        opp.AccountId   = acct.Id;
        opp.RecordTypeId = oppRecType.get(0).id;
        insert opp;
        
    Opportunity opp2     = new Opportunity();
        opp2.Name        = 'test opp2';
        opp2.CloseDate   = system.today()+1;
        opp2.StageName   = 'Initial Pitch/Demo';
        opp2.Use_Case__c = 'Brand Tracker';
        opp2.AccountId   = acct.Id;
        opp2.RecordTypeId = oppRecType.get(0).id;
        insert opp2;
       

    ContentVersion contentVersion = new ContentVersion(
          Title          = 'a picture',
          PathOnClient   = 'Pic.jpg',
          VersionData    = Blob.valueOf('Test Content'),
          IsMajorVersion = true);
        insert contentVersion; 
        
List<ContentDocument> documents = [SELECT Id, Title, LatestPublishedVersionId FROM ContentDocument];

//create ContentDocumentLink  record 
    ContentDocumentLink cdl = New ContentDocumentLink();
        cdl.LinkedEntityId = opp.id;
        cdl.ContentDocumentId = documents[0].Id;
        cdl.shareType = 'V';
        cdl.visibility = 'AllUsers';
        insert cdl;
        
List<Opportunity> updateList = new List<Opportunity>();

List<ContentDocumentLink> cdl2 = [Select Id from ContentDocumentLink where LinkedEntityId =:opp.Id];
            List<Opportunity> oldOpp = [Select id from Opportunity where Name = 'test opp'];
                for (Opportunity runUpdate : oldOpp){
                    runUpdate.stageName = 'Closed Won (R)';
                    updateList.add(runUpdate);
                    system.debug(runUpdate.stageName);
                    update updateList;
                    System.assertEquals(documents.size(), 1);
                }
             }
        catch(Exception e){
            System.Assert(e.getMessage().contains('Please ensure the contract is attached prior to closing this Opportunity'));
        }
            test.stopTest();
    }

}
I have a question on how to build a round robin trigger. We are trying to replace our Distribution Engine by building our own. I beleive this needs to be done with a trigger and I will list requirements below...

We have a custom object that populates a record when an Opp is made. On the Opp we have different locations (sites) that can be populated based on where the customer is. Each location has different Solution Engineers (SE) that get assigned. This process needs to randomly assign an SE that is within the site. 

So the base logic is whenever an Opp is created with a "site," look at that site and update the SE on the Opp with the name of the next user within that site list.

We have 10 different sites with around 3 SE's each. I was thinking about using a custom setting to house the sites and users. what I am having trouble with is how to tell the trigger who will be next in line on the list. 

Thanks for the help. 
I am new to salesforce. I have a community for my users in sandbox.Community is in the preview mode.The login to the community site is working just fine, i can login to the community with the test user's credentials.The problem is when a user forgets their password and tries to reset it. It sends an email to the user with the template assigned to the Forgot Password community setting. The email template includes the {!Community_URL} merge field. Ideally the email received contains a link to the page with some type of reset token as a parameter(your_community_domain/communitiy_name/login?c=TOKEN),and it should be redirected to the change password page. But When the user clicks on the above link, it gets redirected to the link (your_community_domain/communitiy_name/secur/forgotpassword.jsp?r=some token) which redirects to login page and thus there is no way for them to reset their password. Interesting thing is as community is in preview mode ideally it should not be sending any forgot password mails, but in this case it is sending mail with wrong url.

So what should I do to fix this issue? Any kind of help will be appreciated.Thanks.