• Bryan James
  • SMARTIE
  • 560 Points
  • Member since 2015
  • Software Engineer
  • MapAnything


  • Chatter
    Feed
  • 18
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 60
    Replies
 
visual force:
Code:
<apex:page controller="searchcls" >
  <apex:form >
  <apex:pageBlock >
  <apex:inputText value="{!stringval}"/>
  <apex:commandButton value="search" action="{!search}"/>
  </apex:pageBlock>
  <apex:pageBlock >
  <apex:pageblockTable value="{!acctlst}" var="a">
  <apex:column headerValue="Account Name" value="{!a.name}"/>
  <apex:column headerValue="Fax" value="{!a.Fax}"/>
  <apex:column headerValue="Phone" value="{!a.phone}"/>
  <apex:column headerValue="Billingcountry" value="{!a.billingcountry}"/>
  <apex:column headerValue="Billingstate" value="{!a.billingstate}"/>
  </apex:pageblockTable>
  </apex:pageBlock>
  </apex:form>
</apex:page>

Apex controller:
 public class searchcls {
    public List<Account> acctlst { get; set; }
    public String stringval { get; set; }
    public PageReference search() {
       acctlst = (List<Account>)[FIND: stringval RETURNING Account(name, fax, phone, billingstate, billingcountry)][0];       
         if(acctlst =! null) return 'acctlst';
    if(acctlst == null) return 'unknown';
   }
}
 
I have written a short formula to calculate the average value of multiple currency fields, so that if there is a blank value, it shouldn't be calculated.
Logically everything seems fine, but it is not recognizing the the blank fields

Any help is apperciated.

(ValueA__c +  ValueB__c + ValueC__c ) /
(
IF(ISBLANK(ValueA__c), 0, 1) +
IF(ISBLANK(ValueB__c), 0, 1) +
IF(ISBLANK(ValueC__c), 0, 1)
)

The problem is that wether the fileds are blank or filled the values are divided by 3 which it should be divided only based on the filled fields
I created a free Developer Edition (DE) account to just get OAuth with Salesforce working. I would like to work on some of the Trailhead lessons, but want to do so in a different environment / org. I've seen that you can have multple DE's, but I can't figure out how to set that up. What am I missing?

Thanks, 
Dan
Hi All,

Does anyone have any idea to how to count the number of occurrences of all the elements present in a list ? For Example, I have a list of names.
List is having 10 elements with values {A,B,C,D,A,B,A,A,A,A}. Now here A came 6 times, B came 2 times , C came 1 time and D also 1 time. But I don't know how to do it in apex.
Please help how can I get the count of repeated values in apex.
Hello friends

I have 3 feilds in my form and I need to update only one of them based on a selection
the problem is I want to be able to click a bottun and have the corresponding input field appear or disappear 
is there any way to do that?
Hello, I'm working on integeration of SF with external application and need help wiht JSON and arrays

The following code is working fine and I'm getting what I need:

 Map<String,Object> msg = new Map<String,Object>();
        
 msg.put('channel', '#mychannel');
 msg.put('text', 'Here is my case number');
 msg.put('mrkdwn', true);
 String body = JSON.serialize(msg);

To extend above code, I need to achieve following JSON and not sure I can get this. Hope someone can help with this.
{
   "channel": "#mychannel"
    "text": "Here is my case number",  
    "attachments": [
        {
            "text": "And here is an attachment!",
            "color":"good",
            "footer":"End of Message"
        }
    ]
}


Thanks in advance,
P
I have added the below on visualforce page and added to a page layout but it does not display properly. Can you have a look and let me know what is wrong with the code or do I need to write a full visualforce page with the fields.

<apex:page standardController="Service_Request__c" showHeader="true"> <apex:pageBlock > apex:inputText value="{!Service_Request__c.Useful_SQL__c}" rendered="{!(Service_Request__c.Is_this_useful__c == true)}"/> </apex:pageBlock> </apex:page>
Hello,

I am trying to pull data from the Account and Opportunity Objects and insert into a Custom Object named RD_SnapShot_Opportunity. I have the SOQL Query assigned to a list. I think I need to loop through the list and assign the elements in that list to another list and when done insert with a DML statement.

I can not figure out how to take a sObject of Opportuntity that results from the SOQL query and assign to a new List to insert into the table.

Please point me in the right direction. Have I assigned the Opportunity list resulting from the SOQL to the wrong type of sObject?
 
public class RD_SnapshotOpportunityAggregation {
    //To take key information from the Opportunity Object on a schedule to store in the OpportunitySnapshot Object
    
    public static void transferOpportunityData() {
        List<Opportunity> oppList = [ SELECT account.id, 
                                   account.name, 
                                   account.type, 
                                   account.industry, 
                                   account.recordtypeid, 
                                   account.recordtype.name, 
                                   account.ownerId, 
                                   Owner.firstname, 
                                   Owner.lastname, 
                                   Name, 
                                   StageName, 
                                   FTEs__c, 
                                   TotalNumberofSeats__c, 
                                   Amount, 
                                   Annualized_Revenue__c   
                                   FROM Opportunity
                                   ];
        
        // is the RD_Snapshot_Opportunity__c the correct object 
        for(RD_Snapshot_Opportunity__c snap: oppList) {
            //not sure how to assign values to the appropriate field in the snap sObject        
            snap.SsAccountId = oppList[1];
            snap.SsAccountName = oppList[2];
            snap.SsAccountType = oppList[3];
            snap.SsAccountIndustry = oppList[4];
            
            //and each field as we go down the list.
            
        }
        insert opp
    }
}

Any help would be appreciated. Thank you

Thanks in advance,
Robert
Hello, 

I'm accessing Salesforce record data with remote javascript.

This tutorial introduces doing this.

https://developer.salesforce.com/trailhead/en/lightning_design_system/lightning-design-system4

Have a custom fields: due date, complete date, completed by, and assigned to.

When I access these fields with remote objects, they return in a format I don't want displayed.

For example, due date returns: Sat Jan 25 2014 00:00:00 GMT-0800 (PST). I want it to display 01/25/2014
Assigned To return the user id: 005d0000000xlRkAAI. I want it ti display the users first and last name.

How do I do this? This is pure JavaScript, so do I use JavaScript or is there a way to embed Apex in my JS script?
Hello,

Test coverage at 80% and I cant figure out why. Red highlight on Line 11 "return result;" GET request is working fine in workbench.

Account manager class:
 
@RestResource(urlMapping='/Accounts/*/contacts')
global with sharing class AccountManager {

    @HttpGet
    global static Account getAccount() {
        RestRequest request = RestContext.request;
        // grab the accountId from the end of the URL
        String accountId = request.requestURI.substringBetween('Accounts/', '/contacts');
        Account result = [SELECT ID,Name,(SELECT ID,Name FROM Contacts) FROM Account WHERE Id = :accountId ];
        system.debug(result);
        return result;
        
    }
}
Test Class:
 
@IsTest
private class AccountManagerTest {

    @isTest static void testGetAccount() {
        Id recordId = createTestRecord();
        // Set up a test request
        RestRequest request = new RestRequest();
        request.requestUri =
            'https://na1.salesforce.com/services/apexrest/Accounts/'+ recordId+'/Contacts';
        request.httpMethod = 'GET';
        RestContext.request = request;
        // Call the method to test
        Account thisAccount = AccountManager.getAccount();
        // Verify results
        System.assert(thisAccount != null);
        System.assertEquals('Test record', thisAccount.Name);
    }

   

    // Helper method
    static Id createTestRecord() {
        // Create test record
        Account accountTest = new Account(
        Name='Test record');
        insert accountTest;
       
        Contact con1 = new Contact(
        AccountId = accountTest.Id,
        firstName = 'test',
        lastName  =  'tester');
        insert con1;
        return accountTest.Id;
    }          

}


 
I want to add style to the output of a Visualforce IF statement.
 
<li>{! IF( ISBLANK(GoEvent.Event_Time_End__c), '', "End Time: "+GoEvent.Event_Time_End__c+"" ) }</li>

How would I add bold tags to End Time: (<b>End Time: </b>) ?

When I do add bold tags in the if statement it takes them as a string and doesn't style it as bold.
in visual force pageblock can i load 50000 records and can i edit the records?
I created a visualforce PDF page on the opportunity object. I am trying to create a hyperlink formual field to this VF page. This field will be used in opportunity reports. 

However when I click on the link, I recieve the following error:

This site can’t be reached
apex’s server DNS address could not be found.
DNS_PROBE_FINISHED_NXDOMAIN


Here is the formula that I have: HYPERLINK("https://apex/WinLossOpportunityReportPDF?Id="+ Id,"Win/Loss Opportunity Report","_parent")

User-added image
What am I doing wrong? I appreciate any help!

Thanks!
 
Our case maganement is using for customer complaint, internal, safty different types.
Each type needs to have it's own unique case number with special format by sequence.
How can I achieve that?

For exsample,
first person create the case, choose type as "customer complaint", case number will be CCN-0001.
second person create the case, choose type as "safty", case number will be SFN-0001.
third persion create the case, choose type as "customer complaint", case number will be CCN-0002.
etc.

Please help with this question.
Thank you!
Hi - I am attempting to write a case field formula that will calculate the following:
I would like it to calculate the following requirements:
* IF it is after 1 PM MT, then display tomorrow's date. 

Use case example:
It is 10 AM MT on May 2 2016 then it should show/calculate to May 2 2016
It is 2 PM MT on May 2 2016 then it should show/calculate to May 3 2016

Thus far I have the following, but running it tonight May 2 2016 at 8:45 PM MT, it still calculates/displays May 2 2016:
IF( VALUE(LEFT(RIGHT(TEXT(NOW()),9),2)) < 19, TODAY(), TODAY()+1 )

Thanks for the help.
Hi...everbody.I was referring to the visualforce developer guide and I came across this example in vf testing, But I am  gettig an error as failed. I am not bale to save the record may be because I am not able to pass the parameters to URL which is the only condition to save the values to Lead. Here are my vf page and controller codes..

Controller______________________
public class thecontroller {

            private String firstName;
            private String lastName;
            
            private String email;
            private String qp;

            public thecontroller() {
                this.qp = ApexPages.currentPage().getParameters().get('qp');
            }

            public String getFirstName() {
                  return this.firstName;
            }

            public void setFirstName(String firstName) {
                  this.firstName = firstName;
            }

            public String getLastName() {
                  return this.lastName;
            }

            public void setLastName(String lastName) {
                  this.lastName = lastName;
            }

            

            public String getEmail() {
                  return this.email;
            }

            public void setEmail(String email) {
                  this.email = email;
            }

            public PageReference save() {
                PageReference p = null;
                
                if (this.qp == null || !'yyyy'.equals(this.qp)) {
                    p = Page.failure;
                    p.getParameters().put('error', 'noParam');
                } else {
                    try {
                        Lead newLead = new Lead(LastName=this.lastName, 
                                                FirstName=this.firstName, 
                                                 
                                                Email=this.email);
                        insert newLead;
                    } catch (Exception e) {
                        p = Page.failure;
                        p.getParameters().put('error', 'noInsert');
                    }
                }
                
                if (p == null) {
                    p = Page.success;
                }
                
                p.setRedirect(true);
                return p;
            }
 }

and my visualforce code is____________________________
<apex:page controller="thecontroller" tabStyle="Contact">
    
        <apex:pageBlock >
        <apex:form >
           <p>First Name: <apex:inputText value="{!FirstName}"/></p>
           <p>Last Name: <apex:inputText value="{!LastName}"/></p>
           <p>Email: <apex:inputText value="{!Email}"/></p>
           <apex:commandButton value="SAVE" action="{!save}"/>
         </apex:form>
        </apex:pageBlock>
    
 
</apex:page>
Hi Everyone,
           I am running into a small issue here.  Need help just with 1 line of syntax. So I have an object called Project Form , which is looking up to its parent called costpoint project . There is a user field on costpoint record (project team member 1) . I want an apex sharing record (on project form) to get created whenever a project form is added to a particular costpoint project .  All is working well, just the syntax to pass on the Id of the user from parent record seems to go awry . Please help me with the code given below, I have underscored the lines .


 for(Project_Form__c ProjectForm : trigger.new){
            // Instantiate the sharing objects
            teamMemberShr = new Project_Form__Share();
            
            
            // Set the ID of record being shared
            teamMemberShr.ParentId = ProjectForm.Id;
            
            
            // Set the ID of user or group being granted access
            //teamMemberShr.UserOrGroupId = ProjectForm.Costpoint_Project__r.Project_Team_Member_1__c;
            system.debug('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa: ' + ProjectForm.Costpoint_Project__r.Project_Team_Member_1__c);
         
            teamMemberShr.UserOrGroupId = '005G0000001to4iIAA';
            
            // Set the access level
            teamMemberShr.AccessLevel = 'read';
            
            
            // Set the Apex sharing reason for hiring manager and recruiter
            teamMemberShr.RowCause = Schema.Project_Form__Share.RowCause.Project_Team_Member__c;
            
            
            // Add objects to list for insert
            ProjectFormShrs.add(teamMemberShr);
            
        }
Hi,

I have 1 custom object "Loan__c" with master-detail relationship to Account (used for loan of equipments).
I am planning to use the Asset object to manage my stock of loan equipments.
I created a custum field "LoanRef__c" into Asset with look-up relationship to the Loan__c object.

I have a related list "Assets" in the "Loan__c" object - I'd like to add a custom list button there to add existing asset records to this loan. When clicked, the list of all existing asset records must be shown with ability to check the ones I want to add to the loan.

I guess I need to develop an apex class + visual force page.
I'm a novice with apex and visual force but I tried to adapt some similar codes found on the forum, with no success.

Any idea?

Thanks
This field should look at the month and year of deadline__c field (date field). Compare it to the current month/year. If it's within the next 12 months, then 'yes', if not then 'no.

For example: today is 12/20/2016. So, December 2016. The deadline on a record is 1/30/2017. So January 2017. This is within the next 12 months, so it should return a value of 'yes'. If the deadline on a record was 1/15/2018, the value would be 'no' because that month/year is more than 12 months from the current month/year.

The formula that I created isn't working as expected because it factors in the date of the month. Just need it to look at month/year. Here is the formula: IF( Deadline__c >= TODAY() + 365, "Yes", "No")
 
 
visual force:
Code:
<apex:page controller="searchcls" >
  <apex:form >
  <apex:pageBlock >
  <apex:inputText value="{!stringval}"/>
  <apex:commandButton value="search" action="{!search}"/>
  </apex:pageBlock>
  <apex:pageBlock >
  <apex:pageblockTable value="{!acctlst}" var="a">
  <apex:column headerValue="Account Name" value="{!a.name}"/>
  <apex:column headerValue="Fax" value="{!a.Fax}"/>
  <apex:column headerValue="Phone" value="{!a.phone}"/>
  <apex:column headerValue="Billingcountry" value="{!a.billingcountry}"/>
  <apex:column headerValue="Billingstate" value="{!a.billingstate}"/>
  </apex:pageblockTable>
  </apex:pageBlock>
  </apex:form>
</apex:page>

Apex controller:
 public class searchcls {
    public List<Account> acctlst { get; set; }
    public String stringval { get; set; }
    public PageReference search() {
       acctlst = (List<Account>)[FIND: stringval RETURNING Account(name, fax, phone, billingstate, billingcountry)][0];       
         if(acctlst =! null) return 'acctlst';
    if(acctlst == null) return 'unknown';
   }
}
 
I have written a short formula to calculate the average value of multiple currency fields, so that if there is a blank value, it shouldn't be calculated.
Logically everything seems fine, but it is not recognizing the the blank fields

Any help is apperciated.

(ValueA__c +  ValueB__c + ValueC__c ) /
(
IF(ISBLANK(ValueA__c), 0, 1) +
IF(ISBLANK(ValueB__c), 0, 1) +
IF(ISBLANK(ValueC__c), 0, 1)
)

The problem is that wether the fileds are blank or filled the values are divided by 3 which it should be divided only based on the filled fields
Hi. Can you please guide me and help me regarding on the fetching of ID from the URL?

Here is the sample link: https://test.dev.cs7.my.salesforce.com/a0cM00000043ST4

I want to get the ID from the URL using my controller for me to be able to use the ID for Query purposes.

 public List<MyCustomObject> getacts(){          
        List<MyCustomObject> acts = [SELECT Id, a,
                b,
                c
          FROM MyTable where Id ='a0cM00000043ST4'];
        return acts;        
    }    

Can you help me please. Thank you.
I created a free Developer Edition (DE) account to just get OAuth with Salesforce working. I would like to work on some of the Trailhead lessons, but want to do so in a different environment / org. I've seen that you can have multple DE's, but I can't figure out how to set that up. What am I missing?

Thanks, 
Dan
Hi All

My company use Salesforce and I was wondering if there is an app out there where we can scan a business card which will then automatically populate google maps for you on your account?

Can anyone help?

Thank you
Could someone throw light on this what could be the issue in this trigger? JFYI it gives below error 
Apex trigger t2 caused an unexpected exception, contact your administrator: t2: execution of AfterInsert caused by: System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, t2: maximum trigger depth exceeded Case trigger even

trigger t2 on Case (after insert)
{
  List<case> chcase = new List<case>();
  for (Case c: trigger.New)
  {
    Case child = new Case(ParentId = c.Id, subject = c.Subject);
    chcase.add(child);
  }
  insert chcase;  
}
Hi,

I have a quick question regarding how to carry over information into a newly created record. How to have a checkbox check carry over to newly created records and old ones have the checkbox unchecked?

Essentially, we have a Proposal object that we create proposals off of. We may have more than 1 proposal for any one Opportunity. But, only 1 of those Proposals will be the Primary one. The Primary field in the Proposal layout is a checkbox. How can I have that box checked automatically each time a new proposal is made and how can the previous (older proposal(s)) have the Primary box unchecked?

I just can't seem to wrap my head around this. Any help is greatly appreciated!

Thanks


 

Hi 

  We have a requirement to write a formula field for calulating below details are mentioned as follows. 

 1. Unit of Measure ( Which is pick list holds Year/Month/Days) 
 2. List Price 
 3. Quantity 
 4. Subscription Term  

Here Subscription Term is dependent on Unit of Measure
   if Unit of Measure  = Year it will populate ( 1 to 5) 
   if Unit of Measure  = Month it will populate ( 1 to 12) 
   if Unit of Measure  = Days it will populate ( 1 to 31) 

Based on the above value I need to build a formula field 

  IF Unit of Measure = Year = ( List Price * Year * Quantity )

  IF Unit of Measure = Month = ( List Price / 12(Months in year)  * Quantity )
   
  IF Unit of Measure = Days = ( List Price / 365(Days in year) * Quantity )

Please suggest me how to get this formula 

Thanks

Sudhir
  
 
 

  • July 15, 2016
  • Like
  • 0
How do i earn points? Please guide....

Hello everyone,

I need help on writing a trigger. The requirement is to update a field named 'Account Status' on Account on basis of 3 of its child objects activites.

The 3 child objects of Account and its relationship with account :

Finance (custom obj) : look up relationship
Opportunities : Master-Detail relationship
Calls (Custom obj) : look up relationship

So, the requirement is to first check if Account has any Finance records associated with it. If Yes, then check if there are any opportunities linked to it. If the account has any opportunities linked to it, then check if any of its oppportunities were not modified in the last one year. 

If there any opportunities not modified in last one year, then check if the account has any call record created in last one year again.

If the above criteria meets, then the account status field on account should read "disengaged" else should read "engaged".

Can someone help me on this?

Many Thanks,
Tejasvi
 

Hi guys, 

I am running a soql query and I need to get parent (custom object's) field values in the sql. My soql is like this 

select status, subject, whatid, what.name, what.status__c from task

I get the error 
No such column 'status__C' on entity 'Name'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names.

how to get the parent field value from task?

Thanks, 
Prasanna
 
My jquery function :

<script type="text/javascript">
            $j = jQuery.noConflict();
           
           
             $j(document).ready(function(){
            $j('.slds-button').click(function(e) {
                e.preventDefault();
                var dialog = $j('<p>Do you want to proceed ahead for creating Sales Area Data for the company?</p>').dialog({
                    buttons: {
                        "Yes": function() {CallApexMethod2();},
                                                                       
                        "No":  function() {alert('No');},
                        "Cancel":  function() {
                            //alert('you chose cancel');
                            dialog.dialog('close');
                        }
                    }
                });
            });
        });
               
            </script>

my earlier javscript function:

 <script>  
            function myJavascriptFunc(){
                if(confirm('Do you want to proceed ahead for creating Sales Area Data for the company?'))
                {
                    CallApexMethod2() ;
                    return false;
                }
                else {CallApexMethod1() ;
                      return false;
                     }
               
            }       
            </script>

action method on page:

<apex:actionFunction name="CallApexMethod1" action="{!save}" rerender="form"/>  
                    <apex:actionFunction name="CallApexMethod2" action="{!RedirectSalesAreaCompany}"  rerender="form"/>

button for invoking jquery:
<apex:commandButton value="Save" id="saveAction"  styleClass="slds-button slds-button--neutral"/>

I also tried javascript remoting, but coudn't understand how to use it in this context.Please help!!
 
Hi All,

Does anyone have any idea to how to count the number of occurrences of all the elements present in a list ? For Example, I have a list of names.
List is having 10 elements with values {A,B,C,D,A,B,A,A,A,A}. Now here A came 6 times, B came 2 times , C came 1 time and D also 1 time. But I don't know how to do it in apex.
Please help how can I get the count of repeated values in apex.
Hello friends

I have 3 feilds in my form and I need to update only one of them based on a selection
the problem is I want to be able to click a bottun and have the corresponding input field appear or disappear 
is there any way to do that?
Hello, I'm working on integeration of SF with external application and need help wiht JSON and arrays

The following code is working fine and I'm getting what I need:

 Map<String,Object> msg = new Map<String,Object>();
        
 msg.put('channel', '#mychannel');
 msg.put('text', 'Here is my case number');
 msg.put('mrkdwn', true);
 String body = JSON.serialize(msg);

To extend above code, I need to achieve following JSON and not sure I can get this. Hope someone can help with this.
{
   "channel": "#mychannel"
    "text": "Here is my case number",  
    "attachments": [
        {
            "text": "And here is an attachment!",
            "color":"good",
            "footer":"End of Message"
        }
    ]
}


Thanks in advance,
P
Here:
https://developer.salesforce.com/trailhead/manage_the_sfdc_way_motivate_and_champion/motivate_and_champion_facilitating_conversations

Section:
Before the Conversation

Link to "management pack" gets 404 error page
Hi Everyone,
           I am running into a small issue here.  Need help just with 1 line of syntax. So I have an object called Project Form , which is looking up to its parent called costpoint project . There is a user field on costpoint record (project team member 1) . I want an apex sharing record (on project form) to get created whenever a project form is added to a particular costpoint project .  All is working well, just the syntax to pass on the Id of the user from parent record seems to go awry . Please help me with the code given below, I have underscored the lines .


 for(Project_Form__c ProjectForm : trigger.new){
            // Instantiate the sharing objects
            teamMemberShr = new Project_Form__Share();
            
            
            // Set the ID of record being shared
            teamMemberShr.ParentId = ProjectForm.Id;
            
            
            // Set the ID of user or group being granted access
            //teamMemberShr.UserOrGroupId = ProjectForm.Costpoint_Project__r.Project_Team_Member_1__c;
            system.debug('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa: ' + ProjectForm.Costpoint_Project__r.Project_Team_Member_1__c);
         
            teamMemberShr.UserOrGroupId = '005G0000001to4iIAA';
            
            // Set the access level
            teamMemberShr.AccessLevel = 'read';
            
            
            // Set the Apex sharing reason for hiring manager and recruiter
            teamMemberShr.RowCause = Schema.Project_Form__Share.RowCause.Project_Team_Member__c;
            
            
            // Add objects to list for insert
            ProjectFormShrs.add(teamMemberShr);
            
        }