• hai.huang
  • NEWBIE
  • 84 Points
  • Member since 2016


  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 11
    Replies
お世話になっております。

あるボタンをカスタムボタンではなく、項目でボタンを作成し、
そのボタンを押下すると
別の日付項目に自動で現在の日付が入るものを作りたいと思っております。
開発なしでできると嬉しいのですが
何かいい方法はございますでしょうか。

​よろしくお願いします。
Hi ,

I have created a custom VF page to dipsplay list of quotes based on the quote status which is working but the Code coverage on test class is just 68%. 
VF Code
<apex:page StandardController="Quote" extensions="QuotePgeCtrl" sidebar="true" tabStyle="HPQuotes__tab">
    <html>
    <div class="blank">&nbsp;</div>
    <div class="content"><img src="/s.gif" class="pageTitleIcon" title="Quote"/>
    <h1>Quotes</h1><br>
    <font size="5">Home</font></br>
    <div class="blank">&nbsp;</div>
    </div></html>
     
    <apex:form >
        <apex:pageBlock title="Recent Quotes">
                <b>View:  </b>
                <apex:selectList size="1" value="{!quotevalue}">
                <apex:actionSupport event="onchange" action="{!getreviewdqt}" rerender="table1"/>
                <apex:selectOption itemLabel="None" itemValue="None"></apex:selectOption>
                <apex:selectOption itemLabel="Draft Quotes" itemValue="Draft Quotes"></apex:selectOption>
                <apex:selectOption itemLabel="Accepted Quotes" itemValue="Accepted Quotes"></apex:selectOption>
                <apex:selectOption itemLabel="Review Pending Quotes" itemValue="Review Pending Quotes"></apex:selectOption>
                </apex:selectList>
                
               <div style="width:100%; margin-top:5px;height:450px; overflow:scroll;">
                <apex:pageBlockTable id="table1" value="{!quoteList}" var="quotes" >
                <apex:column >
                <apex:facet name="header">Name</apex:facet>
                 <a href="#" onClick="window.parent.location.href='/{!quotes.Id}'">{!quotes.Name}</a>   
                </apex:column>
                
                <apex:column >
                <apex:facet name="header">Quote Number</apex:facet>
                 <a href="#" onClick="window.parent.location.href='/{!quotes.Id}'">{!quotes.QuoteNumber}</a>   
                </apex:column>
                
                <apex:column >
                <apex:facet name="header">Account Name</apex:facet>
                <a href="#" onClick="window.parent.location.href='/{!quotes.Opportunity.Account.Id}'">{!quotes.Opportunity.Account.name}</a>
                </apex:column>
                
                <apex:column >
                <apex:facet name="header">Opportunity Name</apex:facet>
                <a href="#" onClick="window.parent.location.href='/{!quotes.Opportunity.Id}'">{!quotes.Opportunity.name}</a>
                </apex:column>
                
                <apex:column >
                <apex:facet name="header">Status</apex:facet>
                {!quotes.Status}
                </apex:column>
                
                <apex:column >
                <apex:facet name="header">Expiration Date</apex:facet>
                <apex:outputText value="{0,date,MM/dd/yyyy}">
                        <apex:param value="{!quotes.ExpirationDate}"/>
                    </apex:outputText>  
                </apex:column>
  
                <apex:column ><apex:facet name="header">Grand Total</apex:facet>
                <apex:outputText value="{0, number, currency}">
                        <apex:param value="{!quotes.GrandTotal}"/>
                    </apex:outputText> 
                </apex:column>
           
                </apex:pageBlockTable>
                </div>
         </apex:pageBlock>
    </apex:form>
</apex:page>

SC class

public class QuotePgeCtrl
{
   
    public Id quoteId {get;set;}
    public QuotePgeCtrl(ApexPages.StandardController controller)
    {
        sObject quote = controller.getRecord();
        quoteId = (Id) quote.get('Id');
    }

    public string quotevalue{get; set;}
    public list<Quote> quoteList{get; set;}
    public list<Quote> getreviewdqt()
    {
        if(quotevalue == 'None')
       {
            quoteList= new list<Quote>([SELECT Opportunity.Account.Name, QuoteNumber, GrandTotal, Opportunity.name,OpportunityId, Name, IsSyncing, Id, Status,ExpirationDate From Quote WHERE Status ='None']);
      }
       if(quotevalue == 'Draft Quotes')
       {
           quoteList= new list<Quote>([SELECT Opportunity.Account.Name, QuoteNumber, GrandTotal, Opportunity.name,OpportunityId, Name, IsSyncing, Id, Status,ExpirationDate From Quote WHERE Status ='Draft']);
      }
       if(quotevalue == 'Accepted Quotes')
       {
            quoteList= new list<Quote>([SELECT Opportunity.Account.Name, QuoteNumber, GrandTotal, Opportunity.name,OpportunityId, Name, IsSyncing, Id, Status,ExpirationDate From Quote WHERE Status ='Accepted']);
       }
        if(quotevalue == 'Review Pending Quotes')
       {
            quoteList= new list<Quote>([SELECT Opportunity.Account.Name, QuoteNumber, GrandTotal, Opportunity.name,OpportunityId, Name, IsSyncing, Id, Status,ExpirationDate From Quote WHERE Status ='Review Pending']);
       }
      return null;
     }
 }

Test Class
@isTest
public class QuotePgeCtrlTestClass
{
    static testMethod void testMethod1()
    {
        string quotevalue = 'Draft Quotes';
        Quote testQuote = new Quote();
        testQuote.Name='TestQuote' ;
        testQuote.ExpirationDate = system.today();
        testQuote.Status = 'Draft';
        testQuote.OpportunityId = '0066300000341BJ' ;
        System.debug('******************Inserting the record...');
        insert testQuote;
       Test.StartTest();
       
       ApexPages.StandardController sc = new ApexPages.StandardController(testQuote);
        QuotePgeCtrl testQt = new QuotePgeCtrl(sc);
      list<Quote> obj = testQt.getreviewdqt();
       Test.StopTest();
}

What is missign in the code ?

Thanks & regards,
Pallavi
  • September 30, 2016
  • Like
  • 0
SELECT  Id,
                                                Name,
                                                Project__c,
                                                Employee__c,
                                                Client_Pay__c,
                                                Client_Pay_Per_Day__c,
                                                Hours__c,
                                                Date_Of_Service__c,
                                                Invoice__c
                                        FROM    Timecard__c
                                                
                                        WHERE   Employee__c IN  :empids 
                                            AND project__c = :objInvoices.Project__c
                                            AND Date_Of_Service__c >= :objInvoices.Service_Term_From__c
                                            AND Date_Of_Service__c  <= :objInvoices.Service_Term_To__c
                                           order by  Date_Of_Service__c desc ];

 
お世話になっております。

あるボタンをカスタムボタンではなく、項目でボタンを作成し、
そのボタンを押下すると
別の日付項目に自動で現在の日付が入るものを作りたいと思っております。
開発なしでできると嬉しいのですが
何かいい方法はございますでしょうか。

​よろしくお願いします。

お世話になっております。

2つの選択リスト仮にAとBとします。

このAとB、2つの選択リストどちらかを選択しないとエラーになり
さらに両方選択してあった場合にもエラーを出すにはどのような入力規則で
制御するのが良いのでしょうか。

ご指導お願いします。
 

How do i do this..?

Just make sure that your approval process posts the chatter comment as mentioned in the challenge description. have you verified the approval process in your developer org? 
Hi Everyone,

I am trying to create an Apex class which will add the incoming email message which contains projectID in the subject heading into an existing project(custom objec) and discard the email message if it doesn't match any of our project ID.

The test class works fine but is not able to trigger the true condition for the below IF statement even though  the System.debug(myMatcher.group()); contains a valid Name in the project__c database.

IF ([SELECT COUNT() FROM project__c WHERE Name =:myMatcher.group()] == 1)

I have ran a similar Apex code as below below using developer console (Open Execute Anonymous Window) and the three system debugs are returning TRUE result of the IF statement:

USER_DEBUG [6]|DEBUG|UKGWY0000000002
USER_DEBUG [7]|DEBUG|1
USER_DEBUG [9]|DEBUG|Matched

Whereby running the test class returns below DEBUG results:
USER_DEBUG [19]|DEBUG|UKGWY0000000002
USER_DEBUG [58]|DEBUG|No Match Found
String EmailSubject = 'UKGWY0000000002 Testing 1234';
String regexMatch = '^(UKGWY\\d+\\b?)';
Pattern MyPattern = Pattern.compile(regexMatch);
Matcher MyMatcher = MyPattern.matcher(EmailSubject);
if(myMatcher.find())
system.debug(myMatcher.group());
system.debug([SELECT COUNT() FROM project__c WHERE Name =:myMatcher.group()]);
IF ([SELECT COUNT() FROM project__c WHERE name =:myMatcher.group()] == 1)
system.debug('Matched');



My custom email handler class is as below
global class CI_EmailToSalesForce implements Messaging.InboundEmailHandler {
  global Messaging.InboundEmailResult handleInboundEmail(Messaging.InboundEmail email, 
                                                         Messaging.Inboundenvelope envelope) {
  
Messaging.InboundEmailResult result = new Messaging.InboundEmailResult();

//Set the Regex Matching Pattern to look for Project number in the email subject heading
String EmailSubject = email.subject;
String regexMatch = '^(UKGWY\\d+\\b?)';
//Declare a new instance of the Project object
project__c p;

try {

    // Check to see if the email subject contains any project ID
    Pattern MyPattern = Pattern.compile(regexMatch);
    Matcher MyMatcher = MyPattern.matcher(EmailSubject);
    if(myMatcher.find()){
        System.debug(myMatcher.group());
    }    
    //Condition if there is exactly one project ID match from email subject
    if ([SELECT COUNT() FROM project__c WHERE Name =:myMatcher.group()] == 1) {
    system.debug('Matched');
    p = [SELECT ID FROM project__c WHERE Name =:myMatcher.group()];
    Note note = new Note();
    note.Title = email.fromName + '(' +DateTime.now() + ')';
    note.Body = email.plainTextBody;
    note.ParentId = p.Id;
    insert note;

      // Save attachments, if any 
      if (email.binaryAttachments!=null && email.binaryAttachments.size() > 0) { 
        for (Messaging.Inboundemail.BinaryAttachment bAttachment :email.binaryAttachments) { 
        Attachment attachment = new Attachment(); 
        attachment.ContentType = bAttachment.mimeTypeSubType; 
        attachment.Name = bAttachment.fileName; 
        attachment.Body = bAttachment.body; 
        attachment.ParentId = p.Id; 
        insert attachment; 
        } 
      } 
 
      else if (email.textAttachments!=null && email.textAttachments.size() > 0) { 
        for (Messaging.Inboundemail.TextAttachment tAttachment :email.textAttachments) { 
        Attachment attachment = new Attachment(); 
        attachment.Name = tAttachment.fileName; 
        attachment.Body = Blob.valueOf(tAttachment.body); 
        attachment.ParentId = p.Id; 
        insert attachment; 
        } 
      }        

    }
    //Condition if there are more than one project ID match from email subject
    else if ([SELECT COUNT() FROM Project__c WHERE Name =:myMatcher.group()] > 1) {
    system.debug('More than 1 project ID found');
    } else {
      system.debug('No Match Found');
      }
    
    result.success = true;
    } catch (Exception e) {
      result.success = false;
      result.message = 'Oops, I failed.';
    }
   
    return result;
  }
}

Test Class
 
@IsTest
public class CI_EmailToSalesForce_Test {
    static testMethod void testCI_EmailToSalesForce() {
        // Create a new email, envelope and attachment object
        Messaging.InboundEmail email  = new Messaging.InboundEmail();
        Messaging.InboundEnvelope env = new Messaging.InboundEnvelope();
        Messaging.InboundEmail.BinaryAttachment att = new Messaging.InboundEmail.BinaryAttachment();

        // Setup the data for the email
        email.subject = 'UKGWY0000000002 This is a test';
        email.plainTextBody = 'This should become a note';
        env.fromAddress ='something@something.com';
        String contactEmail = 'something@something.com';
        att.body = blob.valueOf('test attachment');
        att.fileName = 'testfile.txt';
        att.mimeTypeSubType = 'text/plain';
        
        email.binaryAttachments = new Messaging.InboundEmail.binaryAttachment[] {att};
        
        // Call the TSG_Email class and test this with the above data
        CI_EmailToSalesForce CI_EmailObjTst = new CI_EmailToSalesForce();

        Test.startTest();
        CI_EmailObjTst.handleInboundEmail(email, env);
        Test.stopTest();

    }
}

​Can anyone tell me what I have done wrong?

Kind regards,
Chris
Hi,
The trailhead project is title is something that I have completed and even data is correctly updated as provided in the module. Still the module doesnt show up as complete and results in error:

Step Not yet complete... here's what's wrong: 
The 'Tim Barr' contact record was not updated correctly in Salesforce. Please check your Heroku Connect setup. 
Note: you may run into errors if you've skipped previous steps.

I could clearly see that my change in updated heroku app traversed to SF Org and updated the required fields. But still I see below error.

Moulde URL:
https://developer.salesforce.com/trailhead/project/quickstart-heroku-connect/qs-heroku-connect-4
Trailhead Module 3:  Create a formula field that determines the number of days between today and the last activity date for a case's account.
Your support team has asked for improved visibility on account activity level at the time they’re helping with customer issues. Specifically, when they’re looking at a case, they’d like to see an at-a-glance view of the number of days since the case’s related account was last active. Create the formula using these requirements.The formula should be on the Case object.
The formula should be of return type Number.
The formula should be named 'Days Since Last Update' and have a resulting API Name of 'Days_Since_Last_Update__c'.
The formula should return the number of days between the account’s Last Activity Date and today.

I created the following:

I created a new custom formula field with return type number and called Days Since Last Update.
I created this formula: Account.LastActivityDate - TODAY()

I get this error message:

Challenge not yet complete... here's what's wrong: 
The 'Days_Since_Last_Update__c' formula field did not return the correct number of days between an Account’s Last Activity Date and today

Can you please assist what I did wrong?  I'm not sure if my formula is even correct with the challenge.  Please help!

Thank you.
Please help me in getting this - I tried, but not working -
https://developer.salesforce.com/trailhead/data_security/data_security_fields