• geeta garg
  • NEWBIE
  • 149 Points
  • Member since 2015

  • Chatter
    Feed
  • 3
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 4
    Questions
  • 23
    Replies
Hi,

I am using the following code below to get the day of the week from the DateTime field, but I am finding that the day of the week is wrong. Essentially i am getting the ((day of the week) - 1) 

For example:
  • For a DateTime value of 4/9/2016, i am getting Friday (when it is really on a Saturday)
  • For a DateTime value of 4/12/2016, i am getting Monday (when it is really on a Tuesday)
Any thoughts on how i can get the correct day of the week?
//for simplicity assume dt variable is defined and set to 2016-04-09 00:00:00. 
String dateStr = dt.format('EEEE'); 

//use for debugging
System.debug('Day of Campaign: '+dateStr+ ' Time: '+dt);

 
  • February 26, 2016
  • Like
  • 0
I need a custom button  that when pressed, changes the owner of the record and saves the record. I have the class already written, I just need the apex page to go along with it. 

Here is the class that I have: 


public with sharing class classSubmitToLegal {

    public Agreement_Request__c a{get;set;}
    public classSubmitToLegal() {
     a = new Agreement_Request__c ();
     a = [select Business_Unit__c from Agreement_Request__c Where Id=: ApexPages.currentPage().getParameters().get('Id')];
    }
    
    public void someMethod() {
      if(a.Business_Unit__c == 'EIS') {
         a.Business_Unit__c = 'EIS Queue';
         update a;
          Apexpages.Message errorMessage = new Apexpages.Message(ApexPages.Severity.Info,'You have changed the owner');
          Apexpages.addMessage(errorMessage);
      } else {
          Apexpages.Message errorMessage = new Apexpages.Message(ApexPages.Severity.Info,'You cannot update');
          Apexpages.addMessage(errorMessage);
      }
    }

}
I have a problem when I created the Validation Rule for the "Creating Validation Rules" Challenge.  I used the following validation rule on the Contact Object:
AND(
NOT(ISBLANK(Account.AccountNumber)),
MailingPostalCode<>Account.ShippingPostalCode)

This works when I test it.  When there is no account, it creates the contact.  When there is an Account associated with the Contact, it prepopulates the Mailing Postal Code with the Billing Zip Code (not the shipping zip code).  If I change it, to match the Shipping Zip Code, I can create the Contact.  If the Zip Code doesn't match then I recieve the message I created saying:  "Contact Mailing Zip Code must match Account Shipping Zip Code".  This seems to be what the challenge is asking.

What could I be doing wrong?  Or is this a problem with the logic for the Challenge?

Kevin

Kev 
Hi All,

I want to show all the fields name of the object in design attribute on which lighting component is added. But i am unable to show the all field.
For ex : I am adding the lighting component on Account object then all the fields of account need to show in design attribute. If i will add on contact then contact field will show.

Please suggest for the above question.

Thanks,
Geeta Garg
Hi All,
I am facing error in the lighting component. When I select the picklist value, first time, everything is working fine. But at the second time , this error message is displayed.

Apex controller is working fine for the second time but page is displaying the following error message.User-added image

Thanks,
Geeta Garg
Hi,  
This is the request part of Webservice Api.
curl -v -u user@yourcompany.com:test -F "attachments[]=@/path/to/attachment1.ext" -F "attachments[]=@/path/to/attachment2.ext" -F "email=example@example.com" -F "subject=Title" -F "description=this is a sample" -X POST 'https://domain.test.com/api'
 I want to use this request in Apex class. How can i use it? Please suggest.  
Thanks,
Geeta Garg
I have vf page which is used to export data into csv format.But I want to redirect the page after loading and saving the csv file.
<apex:page standardController="Account" extensions="redirectme" cache="true" contentType="text/csv#ExportAccountdata.csv" language="en-US" > Id,Name,Phone
<apex:repeat value="{!acc}" var="account"> {!account.id},{!account.name},{!account.phone}
</apex:repeat>
</apex:page>
Controller of Vf page :-
public class redirectme {

    public redirectme(ApexPages.StandardController controller) {
    acc=[select id,name,phone from account];

    }

public list<account> acc{
get;
set;
}

    
    public pagereference redirect()
    {
    Pagereference pg=new pagereference('https://geeta-dev-ed.my.salesforce.com/001?fcf=00B28000003KuCF');
    pg.setredirect(true);
    return pg;
    }

}



 
Dear Team,
How can our company (blue-infinity, Switzerland) get the Lightning Experience Accreditation?
Thanks for your indications.
Grégoire Faist
Hi,  
This is the request part of Webservice Api.
curl -v -u user@yourcompany.com:test -F "attachments[]=@/path/to/attachment1.ext" -F "attachments[]=@/path/to/attachment2.ext" -F "email=example@example.com" -F "subject=Title" -F "description=this is a sample" -X POST 'https://domain.test.com/api'
 I want to use this request in Apex class. How can i use it? Please suggest.  
Thanks,
Geeta Garg
I have built a trigger and was at 77% code coveragae until I had to make a modifcation and add in that If statement on line 5.  Now my code coverage is at 7%.  What am I doing wrong?


Tigger – I continue this same core code from line 3 to 7 – 11 times just with a different Transaction Territory
trigger OpportuntiyTerritoryID on Opportunity (before update) 
{
    //Id territortyId = [select id from Territory where name ='dfdfd'];
    for(opportunity opp : trigger.new)
      if (opp.account != null)
        if (opp.Transaction_Territory__c == 'South East')
    {Opp.Territory2Id = '0MIE0000000KyyT';// Try to get this ID from Query for using for loop(like territortyId)
  


My Test Class – this repeats 7 times
public class OpportuntiyTerritoryIDTest     

    static testMethod void test ()
    {
    Account acc = new Account(Name = 'Test Account');
    insert acc;
    
     Opportunity opp = new Opportunity(Name='TEST opp', StageName='Closed Won', Probability = 100, CloseDate=system.today());     
       opp.Type ='New Sale';
       opp.accountid = acc.id;
       opp.Transaction_Territory__c = 'Great Lakes';
       opp.activationcode__c = '00001234561';
       insert opp;
       opp.Transaction_Territory__c = 'HI';
       opp.Source_Type__c = 'Carbonite';
       update opp;
  } 
 
I have vf page which is used to export data into csv format.But I want to redirect the page after loading and saving the csv file.
<apex:page standardController="Account" extensions="redirectme" cache="true" contentType="text/csv#ExportAccountdata.csv" language="en-US" > Id,Name,Phone
<apex:repeat value="{!acc}" var="account"> {!account.id},{!account.name},{!account.phone}
</apex:repeat>
</apex:page>
Controller of Vf page :-
public class redirectme {

    public redirectme(ApexPages.StandardController controller) {
    acc=[select id,name,phone from account];

    }

public list<account> acc{
get;
set;
}

    
    public pagereference redirect()
    {
    Pagereference pg=new pagereference('https://geeta-dev-ed.my.salesforce.com/001?fcf=00B28000003KuCF');
    pg.setredirect(true);
    return pg;
    }

}



 
When we can use and shouldn't use seeallData=true

what are adventages and disadventages of seeallData=true and seeallData=false?
Hi everyone,

So this is my first attempt at writing an Apex trigger and it seems to be working fine in the Sandbox.
I've now got a couple of questions that I'm hoping you could help me with:

1. You can see the trigger is simple enough, just a bunch of IF statements but it does the job. As I'm only starting in this area I'm unsure if I took the right approach and if it even complies with best practices used with Apex triggers.
Could or should I have used FOR loops instead? Would any code variations be more suitable?
Are there any risks of falling in an endless loop?

2. How do I go about creating Test Classes for this trigger?

Any help with the above is welcome! Thanks a million guys!

Code snippet
Hi,

I am using the following code below to get the day of the week from the DateTime field, but I am finding that the day of the week is wrong. Essentially i am getting the ((day of the week) - 1) 

For example:
  • For a DateTime value of 4/9/2016, i am getting Friday (when it is really on a Saturday)
  • For a DateTime value of 4/12/2016, i am getting Monday (when it is really on a Tuesday)
Any thoughts on how i can get the correct day of the week?
//for simplicity assume dt variable is defined and set to 2016-04-09 00:00:00. 
String dateStr = dt.format('EEEE'); 

//use for debugging
System.debug('Day of Campaign: '+dateStr+ ' Time: '+dt);

 
  • February 26, 2016
  • Like
  • 0
I need a custom button  that when pressed, changes the owner of the record and saves the record. I have the class already written, I just need the apex page to go along with it. 

Here is the class that I have: 


public with sharing class classSubmitToLegal {

    public Agreement_Request__c a{get;set;}
    public classSubmitToLegal() {
     a = new Agreement_Request__c ();
     a = [select Business_Unit__c from Agreement_Request__c Where Id=: ApexPages.currentPage().getParameters().get('Id')];
    }
    
    public void someMethod() {
      if(a.Business_Unit__c == 'EIS') {
         a.Business_Unit__c = 'EIS Queue';
         update a;
          Apexpages.Message errorMessage = new Apexpages.Message(ApexPages.Severity.Info,'You have changed the owner');
          Apexpages.addMessage(errorMessage);
      } else {
          Apexpages.Message errorMessage = new Apexpages.Message(ApexPages.Severity.Info,'You cannot update');
          Apexpages.addMessage(errorMessage);
      }
    }

}
i have a pincode field  write only on number  limit six only how it is posible between  500000 to 900000
I have a problem when I created the Validation Rule for the "Creating Validation Rules" Challenge.  I used the following validation rule on the Contact Object:
AND(
NOT(ISBLANK(Account.AccountNumber)),
MailingPostalCode<>Account.ShippingPostalCode)

This works when I test it.  When there is no account, it creates the contact.  When there is an Account associated with the Contact, it prepopulates the Mailing Postal Code with the Billing Zip Code (not the shipping zip code).  If I change it, to match the Shipping Zip Code, I can create the Contact.  If the Zip Code doesn't match then I recieve the message I created saying:  "Contact Mailing Zip Code must match Account Shipping Zip Code".  This seems to be what the challenge is asking.

What could I be doing wrong?  Or is this a problem with the logic for the Challenge?

Kevin

Kev 

[Error] Error: Compile Error: Initial term of field expression must be a concrete SObject: String at line 6 column 12


public class CountryClub {

    public String imageURL{ get; set; }

    public PageReference Upload() {
           imageURL.AuthorId = UserInfo.getUserId(); 
           imageURL.FolderId = UserInfo.getUserId(); // put it in running user's folder 
             try { 
              insert imageURL; 
               } catch (DMLException e) { 

               ApexPages.addimage(new ApexPages.message(ApexPages.severity.ERROR,'Error uploading file')); 
              }    
//Add more logic here
        return null;
    
   }

    public PageReference Browse() {

imageURL.AuthorId = UserInfo.getUserId(); 
          imageURL.FolderId = UserInfo.getUserId(); // put it in running user's folder 
             try { 
              insert imageURL; 
               } catch (DMLException e) { 

               ApexPages.addimage(new ApexPages.message(ApexPages.severity.ERROR,'Error uploading file'));
}
    //Add more logic here
        return null;
    

}
}
Hi all, 

Whenever i try to use the test class method 'getStandardPricebookId()'  ,im getting the error 'Method does not exist or incorrect signature'.
Any help is highly appreciated.
Thanks in advance.
Im on API version 30.

Hi,

My goal is to call a controller from a visualforce component using Javascript remoting and then to update the visualforce chart with the result.

 

The javascript remoting call works fine and I can see in the debug console that it receives the correct values as well. But how do I update the chart with this data?

 

Here's the javascript code. testCharts is my controller and getRemoteData is the RemoteAction method.

 

<script type="text/javascript">
function getOppChart() {
var year = '2013';

Visualforce.remoting.Manager.invokeAction(
'{!$RemoteAction.testCharts.getRemoteData}',
year,
function(result, event) {
if (event.status) {
	// Actions here, update VF chart?
} else if (event.type === 'exception') {
	document.getElementById("responseErrors").innerHTML = event.message;
} else {
	document.getElementById("responseErrors").innerHTML = event.message;
}
}, 
{escape: true}
);
}
</script>

The visualforce chart component. The data attribute is required. How do I pass the result from the javascript function here? I would like to make this dynamic so that when I select a value in a picklist on the page a new call is made and the chart is refreshed. But as a start I'd just like to know how to get the result there. If I was just using a controller I would just put the method name in the data attribute, i.e. data="{!oppData}".

 

<apex:chart height="300" width="600" data="???">
	<apex:axis type="Numeric" position="left" fields="data,data2" 
	title="Total Order value" grid="true"/>
	<apex:axis type="Category" position="bottom" fields="name" 
	title="Month of the Year">
	</apex:axis>
	<apex:lineSeries axis="left" fill="true" xField="name" yField="data2"
	markerType="cross" markerSize="4" markerFill="#FF0000"/>
</apex:chart>

 The reason I am not using the Apex controller methods directly is because of three reasons.

- I hope the user will find this more reponsive

- I want to be able to rerender the charts

- I just want to make it work!!!

 

Can't find anything on the boards or google. Anyone got ideas?? Much appreciated!

 

Thanks / Niklas

 

Hi,

 

Can any one plz tell me the differences between DataLoader and Import wizard?

 

 

 

Error: Compile Error: Return value must be of type: LIST<Account> at line 4 column 9 <-- this is the error i get when i try to run the following code:

 

public class MyController {
    public List<Account> getMyAccounts ()
    {
        return [select Id, Name, Accountnumber from Account
        Order by LastmodifiedDate DESC Limit 10];
    }
}

 

please let me know where i went wrong. Thank you.

Hello All,
I have completed this challenge.

1-For this first you need to create a helper formula field(type-percent) 
Percent Completed :
(DATEVALUE( CreatedDate ) - CloseDate )/100


2- Then you need to create the actual formula field (type- text) by using the helper formula field.
Opportunity Progress :

IF( Percent_Completed__c <=25,"Early", 
IF(Percent_Completed__c <=75,"Middle", 
"Late"))

Thanks,
Nida