• Bishal Singh 12
  • NEWBIE
  • 75 Points
  • Member since 2018

  • Chatter
    Feed
  • 3
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 6
    Replies
Create a field on the Account object called 'Number_of_Contacts__c' of type Number. This field will hold the total number of Contacts for the Account.
Create an Apex class called 'AccountProcessor' that contains a 'countContacts' method that accepts a List of Account IDs. This method must use the @future annotation.
For each Account ID passed to the method, count the number of Contact records associated to it and update the 'Number_of_Contacts__c' field with this value.
Create an Apex test class called 'AccountProcessorTest'.
Hello Guys,

I was working on one interesting scenario.
I am creating a record using process builder and I have date field called "Start_date__c", I want to pass a value "01/08/CURRENTYEAR" into that field.
Can anyone help me out in doing this if possible. i believe it should be done through formula field.
Object: Lead
Formula feild: Lead_Age__c
Custom feild: Lead_Age2__c

I wrote some triggers but somehow they are not working... thank you in advance 
Trying to build a webpage for teams to be able to submit cases and attachments. For some reason I am getting a "Unknown constructor 'attachController.attachController(ApexPages.StandardController controller)'" error and even though I add the standard set controller I am still getting an error. Am I missing something on this for where I need to be adding this? 

VF: 
<apex:page Standardcontroller="Case" extensions="attachController" showheader="false" >
    <html lang="en">
        <head>
            <link href="https://use.fontawesome.com/releases/v5.4.2/css/all.css" rel="stylesheet" media="screen"/>
            
            <!-- Bootstrap -->
            <link href="https://cdn.rawgit.com/creativetimofficial/now-ui-kit/2e8e665f/assets/css/bootstrap.min.css" rel="stylesheet" media="screen"/>
            <link href="https://cdn.rawgit.com/creativetimofficial/now-ui-kit/2e8e665f/assets/css/now-ui-kit.min.css?v1.2.0" media="screen"/>
            <title>Submit a Case</title>
            
            <style>
                
                p, li, .description{
                font-weight: 400;
                line-height: 1.8rem;
                }
                
                .paddingTop{
                padding-top: 2rem;
                }
                
                .background-black{
                background: #2196f3;
                }
                
                .background-black:hover, .background-black:focus{
                background: #2386d3 !important;
                }      
                
                section .section-inner h2{
                color: #fff;
                }
                
                .round {
                border-radius: 100px;
                margin: 0;
                color: #9a9a9a
                }
                
                .longBox{height: 100px;}
                
                
                @media screen and (max-width: 500px){
                .brand .h1-seo{
                font-size: 2.2rem;
                }
                
                }
                
            </style>
        </head>
        <body>
            <div class="container">
                <apex:form >
                    <form class="form-signin"><br/><br/><br/>
                        <br/><h2 class="form-signin-heading">Create a Ticket</h2><br/><br/>
                        <h5 class="form-signin-heading">Email</h5><br/>
                        <apex:inputfield styleClass="inputGroupSelect01 custom-select round form-control" value="{!case.Email__c}" required="true"/>
                        <br/><h5 class="form-signin-heading">Subject</h5><br/>
                        <apex:inputfield styleClass="inputGroupSelect01 custom-select round form-control" value="{!case.Subject}" required="true"/>
                        <br/><h5 class="form-signin-heading">What are you experiencing?</h5><br/>
                        <apex:inputfield styleClass="inputGroupSelect01 custom-select round form-control" value="{!case.What_are_you_experiencing__c}" required="true"/>
                        <br/><h5 class="form-signin-heading">Where is the location of your issue?</h5><br/>
                        <apex:inputfield styleClass="inputGroupSelect01 custom-select round form-control" value="{!case.Location_of_issue__c}" required="true"/>
                        <br/><h5 class="form-signin-heading">Source Type</h5><br/>
                        <apex:inputfield styleClass="inputGroupSelect01 custom-select round form-control" value="{!case.Source_Type__c}" required="true"/>
                        <br/><h5 class="form-signin-heading">Description</h5><br/>
                        <apex:inputfield styleClass="inputGroupSelect01 custom-select round form-control longBox" value="{!case.Description}" required="true"/><br/>
                        <button class="btn btn-primary btn-block btn-lg background-black btn-round round " type="submit">Submit</button>
                        <apex:pageBlock >
                            <apex:pageBlockButtons location="top">
                                <apex:commandButton id="uploadAttachment" value="Upload" action="{!uploadAttachment}"/>
                            </apex:pageBlockButtons>
                            
                            <apex:pageBlockSection columns="1">
                                <apex:pageBlockSectionItem >
                                    <apex:outputLabel >Attachment</apex:outputLabel>
                                    <apex:inputField value="{!cs.Name}"/>
                                </apex:pageBlockSectionItem>
                                <apex:pageBlockSectionItem >
                                    <apex:outputLabel >Attachment</apex:outputLabel> 
                                    <apex:inputFile value="{!document}" accept="doc, docx, txt, pdf, xlsx" filename="{!fileName}" contentType="{!contentType}" filesize="1000" size="50" /> 
                                </apex:pageBlockSectionItem>
                            </apex:pageBlockSection>
                        </apex:pageBlock>>
                    </form>
                    
                </apex:form>
            </div>
            <!-- /container -->
            <!-- Bootstrap core JavaScript
================================================== -->
            <!-- Placed at the end of the document so the pages load faster -->
        </body>
    </html>
</apex:page>

Apex:
public class attachController {
    
    public List<Attachment> fileList {get; set;}
    public Case cs {get; set;}
    public Attachment attach {get; set;}
    public ApexPages.StandardSetController stdCntrlr {get; set;}
    public attachController(ApexPages.StandardSetController controller) {
        
        stdCntrlr = controller;
    }
    public attachController() {
        cs = new Case();
        
        attach = new Attachment();
        fileList = new List<Attachment>();
        fileList.add(attach);
        //AddAttachs();
    }
    
    public Case getCS(){
        if(cs == null) 
            cs = new Case();
        return cs; 
    }
    
    public List<Attachment> getAttachments(){
        if(fileList == null) 
            fileList = new List<Attachment>();
        return fileList; 
    }
    
    public PageReference AddAttachs() {
        fileList.add(new Attachment());
        return null;
    }
    
    public PageReference uploadAttachment() { 
        insert cs;
        
        if(cs != null) {            
            List<Attachment> attachments = new List<Attachment>();                               
            
            for(Attachment att : fileList)              
            { 
                if(att.name != null && att.body != null)
                    attachments.add(new Attachment(parentId = cs.Id, name = att.name, body = att.body)) ;                
            }
            if(attachments != null){
                upsert attachments;                 
                ApexPages.addmessage(new ApexPages.message(ApexPages.Severity.INFO, attachments.size() + ' file(s) uploaded successfully'));                                              
            }else {
                ApexPages.addMessage(new ApexPages.message(ApexPages.Severity.ERROR, 'Error uploading file'));
            }              
        }                    
        
        return null;      
    }   
    
}

​​​​​​​
Create a field on the Account object called 'Number_of_Contacts__c' of type Number. This field will hold the total number of Contacts for the Account.
Create an Apex class called 'AccountProcessor' that contains a 'countContacts' method that accepts a List of Account IDs. This method must use the @future annotation.
For each Account ID passed to the method, count the number of Contact records associated to it and update the 'Number_of_Contacts__c' field with this value.
Create an Apex test class called 'AccountProcessorTest'.
Hi all,

Can we have Cron Expression to schedule Job on every 2nd Week only on(Monday, Wednesday and Friday) only at 12 AM.?
What cron we can use for this?

Any help would be highly appreciated.
Hello Guys,

I was working on one interesting scenario.
I am creating a record using process builder and I have date field called "Start_date__c", I want to pass a value "01/08/CURRENTYEAR" into that field.
Can anyone help me out in doing this if possible. i believe it should be done through formula field.