• Frédéric Trébuchet
  • SMARTIE
  • 1805 Points
  • Member since 2014
  • EI-Technologies


  • Chatter
    Feed
  • 24
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 241
    Replies
In my Apex Code I have Default Start time and Default End Time named as start and stop, code as follows
 time start = time.newInstance(8,30,0,0);
 time stop = time.newInstance(17,0,0,0);

and I am getting start time and endtime from Object [field type DateTime] from that i am getting only time in Starttime and Endtime, code as follows

time Starttime = Time.newInstance(SSJ.Start_Date_and_Time__c.hour(),SSJ.Start_Date_and_Time__c.minute(),SSJ.Start_Date_and_Time__c.second(),SSJ.Start_Date_and_Time__c.millisecond());

 time Endtime = Time.newInstance(SSJ.End_Date_and_Time__c.hour(),SSJ.End_Date_and_Time__c.minute(),SSJ.End_Date_and_Time__c.second(),SSJ.End_Date_and_Time__c.millisecond());

Now i want to find the difference between
Stop to Starttime and
Start to Endtime . how to calculate this?

Thanks and Regards 
S.Mohan
 
What is the trigger.newmap and trigger.oldmap and when to use these two in triggers? can anyone share me the answer for this in detail?
Well, all I can say is that it does add an account, and if you send it a blank string, it does return a NULL, so I am wondering what I did wrong. Here is the code:

public class AccountHandler {

    public static ID  insertNewAccount(String myStr) {
        try {
            Account acct = new Account(Name=myStr);
            insert acct;
            
            return(acct.id);
            
        } catch (DmlException e) {
            System.debug('A DML exception has occurred:' + e.getMessage());
            return(NULL);
        }
        
    }
            
}

Thanks in advance for the help,

Feeling dumb
I am new to salesforce and I want to connect to the salesforce database from my custom .NET Application and not via salesforce.com. How can this be made possible? How do I get started?
Hi,

I have a post install script. All I want to do is add a record to a custom object (which comes with the package). In the record that i want to add automatically, I want to get details from the logged in User, and generate a random number.

After install I get the following error.
Unexpected Error	 	The package installation failed. Please provide the following information to the publisher:

Organization Name: xx
Organization ID: xx
Package: xx
Version: 1.0
Error Message: The post install script failed.
What am I doing wrong here? Please help. Thanks in advance.

Below given is my Post Install code
 
global class PostInstallClass implements InstallHandler {
    global void onInstall(InstallContext context) {
        if(context.previousVersion() == null) {
            string userEmail = UserInfo.getUserEmail();
            string firstName = UserInfo.getFirstName();
            string lastName  = UserInfo.getLastName();
            string orgName   = UserInfo.getOrganizationName();
            string recName  = 'MyRec1';
            string uniqueId   = generateRandomString(40);
            
           MyCustomObject__c c = new MyCustomObject__c(UniqueID = uniqueId, Your_Company__c = orgName, Name = recName, First_Name__c = firstName, Last_Name__c = lastName, Email__c = userEmail);
            insert c;
       }
    }

public static String generateRandomString(Integer len) {
        final String chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz';
        String randStr = '';
        while (randStr.length() < len) {
           Integer idx = Math.mod(Math.abs(Crypto.getRandomInteger()), 62);
           randStr += chars.substring(idx, idx+1);
        }
        return randStr;
    }

}
I am having problems with this query, which I believe to be similar to the second basic one.

SELECT Order_Value__C
    ( SELECT Warehouse__C FROM Order_Detail__C )    FROM Order_header__c

I assume the relationship here is the same?
SELECT Id, Name, Industry, AnnualRevenue,
    ( SELECT Name, Email, BirthDate FROM Contacts )    FROM Account

It says

MALFORMED_QUERY:
( SELECT Warehouse__C FROM Order_Detail__C
^ ERROR at Row:2:Column:6
unexpected token: 'SELECT'

In our System API Name Order_Details__c show
Field Label Order Header
API NAME Order_Header__c
Data Type Master-Detail(Sales Order) 

I assume the relationship would be the same and it would work?

Individually both of these work
This works SELECT Order_Value__C FROM Order_header__c
This works SELECT Warehouse__C FROM ORDER_Detail__C
I have a picklist with 4 text values. I want to assign a numeric value to each text value. I then want to multiply the chosen value by a number field.  Can anyone help me with the syntax?  

Picklist field = Plan_object__c
Picklist Values = Low,High,Medium,None
Number Field = R_Complex__c 
Hello...
I am facing problem in solving challange 
error says..

Challenge not yet complete... here's what's wrong: 
Executing the 'searchForContacts' method failed. Either the method does not exist, is not static, or does not return the expected contacts.
 my code is.

public class ContactSearch {
 public static List<List<SObject>> searchForContacts(String name) {
       
     List<List<SObject>> result= [FIND :name IN ALL FIELDS 
                                      RETURNING  Contact(LastName, MailingPostalCode)];
        return result;
      
}
}

please help

Thanks in Advance,
Sanket Supe
I want to compare two list in which values are stored in a different order . I am inserting the list into different maps . how to compare that the data in list 1 is present in list 2.
I am going through the Trailhead lessons and for some reason am hung up on this one.  The test is to:
Create a Visualforce page that displays the first name of the logged-in user.
* The page must be named 'myHelloWorldVF'.
* The displayed user information must be generated dynamically from the logged-in user.

The code I have for this is:
<apex:page >
    {! $User.FirstName}
</apex:page>

For some reason Trailhead keeps coming back with the error:
The Visualforce page did not fit the criteria. The first name of the logged in user was not output using dynamic global variables.

Can anyone give insight into what I am doing wrong?  Not looking for the answer, just guidence in what needs to be looked at.

Thanks!
There appears to be a bug in Visualforce where inputField defaults do not display if the field is initially hidden and then a rerender displays the field.  If the field is initially visible then the default value is displayed on page load and after a rerender.  I have tested this on the latest API (32.0) and have a simple page example below that can be used to try to reproduce the issue.  In the code example below, the TrackingNumber__c field on opportunity has a default formula value of $User.LastName.  When you click the refresh button it will set a boolean flag (show) which will cause the inputfield to be displayed after the rerender completes.  If you remove the rendered attribute hiding the inputfield you will notice that the field default does display correctly even if you hit the refresh button.

<apex:page standardcontroller="opportunity" extensions="testoppextension">
    
    <apex:form id="frm">

        <apex:inputField value="{!opportunity.TrackingNumber__c}" rendered="{!show}"/>
        
        <apex:commandButton value="refresh" action="{!refresh}" rerender="frm"/>
        
    </apex:form>
    
</apex:page>

public class testoppextension {

    public boolean show {get;set;}
    
    public testoppextension(ApexPages.StandardController std){
        show = false;
    }
    
    public void refresh(){
        show = true;
    }
}
Hi, I'm struggling with a SOQL I'm working on. I'm trying to show a chart of # of Won Deals this Fiscal Year grouped by Close Month. Is this possible? 
Hello

When i am Uploading some data around 15000 records using apex.
i am facing this error "regex too complicated"
in this line,like when i split complete rows by new line after that doing the next steps.
When i upload lesser like 1000 round it is successfull.
filelines = nameFile.split('\n');
Could any one please help me out or suggest me any way to free out from this error.

Regards
Srinivas


 
  • December 10, 2014
  • Like
  • 0
Hi all,

I have created radio buttons that uses a Picklist field. Is there a way of maing one of the values default? 

I need the 'Not Required' value to be default.

Many thanks
 
<apex:page standardController="Everton_Users__c" showHeader="true"  >
<apex:sectionHeader title="Everton Users"
                 subtitle="New Everton User"/>
<apex:form >
<apex:pageblock mode="edit"  >
 <apex:pageBlockButtons location="both">
            <apex:commandButton value="Save" action="{!save}"/>
            <apex:commandButton value="Cancel" action="{!cancel}"/>
        </apex:pageBlockButtons>

<apex:pageBlockSection title="Information" columns="2">
 <apex:inputField value="{!Everton_Users__c.name}" Required="True"/>
 <apex:inputField value="{!Everton_Users__c.Start_Date__c}"/>

 </apex:pageBlockSection>
 
 <apex:pageblockSection title="ITSS Signed Policies" columns="1" >
 <apex:inputField value="{!Everton_Users__c.ITSS_Acceptable_Usage_Policy__c}"/>


 
 </apex:pageblocksection>


<apex:pageblockSection title="Equipment Control" columns="2"  >
        <apex:selectRadio label="Sharefile:" value="{!Everton_Users__c.Sharefile__c}" required="true" style="margin-top: -10px;">
        <apex:selectOption itemLabel="Not Required" itemvalue="Not Required"/>
        <apex:selectOption itemLabel="Required" itemvalue="Required"/>
        <apex:selectOption itemLabel="Enabled" itemvalue="Enabled"/>
        <apex:selectOption itemLabel="Disabled" itemvalue="Disabled"/>
        </apex:selectRadio> 
          
        </apex:pageblocksection>
        
       
</apex:pageblock>
</apex:form>
</apex:page>

 
Hello, I'm trying to do the Using Simple Variables and Formulas challenge from Intro to Programmatic App Development. Is asking for:
Create a Visualforce page that displays the first name of the logged-in user.
I created a VF page named as is requested, with the following code:
<apex:page>
    {! $User.FirstName } 
</apex:page>
But when trying to check the challenge, I get the error:
Challenge not yet complete... here's what's wrong: 
The Visualforce page did not fit the criteria. The first name of the logged in user was not output using dynamic global variables.

What am I doing wrong?
Thank you!
Am I the only one that gets error on Unit 1.  It's something simple and I get the error of 'Set Case to Escalated' worflow update field is missing... which is not, it's already there.

Cheers

 
  • December 03, 2014
  • Like
  • 0

Hey community,

I'm struggling with the logic of the task...

To complete this challenge, add a validation rule which will block the insertion of a contact if the contact is related to an account and has a mailing postal code (which has the API Name MailingPostalCode) different from the account's shipping postal code (which has the API Name ShippingPostalCode).Name the validation rule 'Contact must be in Account ZIP Code'.

A contact with a MailingPostalCode that has an account and does not match the associated Account ShippingPostalCode should return with a validation error and not be inserted.

The validation rule should ONLY apply to contact records with an associated account. Contact records with no associated parent account can be added with any MailingPostalCode value. (Hint: you can use the ISBLANK function for this check)

Here is what I got so far:

AND(
 NOT(ISBLANK(MailingPostalCode)),
 MailingPostalCode  <>  Account.ShippingPostalCode )

I THINK I know how to see if the contact mailing zip is not the same as the account shipping zip, and only if the is not blank.

The part I am stuck on is if the "Contact records with no associated parent account can be added with any MaiilingPostalCode value"...

I don't know what to do with that.

Also, I am now getting the error message when I recheck challenge:

Challenge not yet complete... here's what's wrong: 
There was an unexpected error in your org which is preventing this assessment check from completing: System.DmlException: Insert failed. First exception on row 0; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, Contact_must_be_in_Account_ZIP_Code: [] 


Double help, please.

I have a two picklist values.
1.Country  2.State
if i select the india then the  state picklist shoud have states belongs to india.Like that Us also

Can Any one help me.If possible provide the code

Thanks 
Hi everyone,

Does anyone know the different badges that can be achieved by contributing to this forum (newbie, smartie, etc) and how many points match each level?

Regards,
Fred
 
Hi there,

I'd like to update my LinkedIn profile in my settings but the message "Wrong URL format" appears even if I respect the default format.
Any idea?

Thanks,
Fred
 
Hi everyone,

Does anyone know the different badges that can be achieved by contributing to this forum (newbie, smartie, etc) and how many points match each level?

Regards,
Fred
 
The first challangeof this Superbadge seems to be problematic, showing the following message:
Challenge Not yet complete... here's what's wrong:
We could not find enough records in the 'Contacts' object. There should be at least 100 from the import.

What is interesting is that everything seems complete to me! I have inserted 100 contacts and 100 accounts, and of course all other items (Opportunities and Contact Hobbies).

Any idea why I see this error message?
I have accounts in Salesforce that have a field that contains the ID of that same account in our Oracle ERP system.

I would like to be able to import Service Contracts and tie them to the correct account, but the only information that I have available to me in the extract from Oracle is the Oracle ID, not the Salesforce Id.

Is there a way to accomplish this? (I want to automate this, so getting the Salesforce ID and performing Vlookups, etc. isn't a workable solution).

Thanks for any help!!

 
What is data config file?
what is process config file?
which time zone used in data loader?
how to enable european date format in data loader?
​how to run data loader from command prompt?
For the T-Shirt challange , I try to import the contacts_to_import.csv file which were downloaded from the challange page but I got the folowing error 
contacts_to_import.csv
There was a problem uploading the CSV file. Try again, or choose another file.
I have an Apex Trigger that counts the number of Projects that have been created on an Account, and i realized today that if you create the first Project on an Account the field displays 1, but then if you delete that Project the field still displays 1. I need it to go back to zero if there are no Projects on the Account anymore.

Any help would be greatly appreciated,
Hey ,

I´ve create a buttom where it creates a password based on the birthday of my account (YYYYMMDD) , the problem is that when we the day/month as a zero its ignored . Any one has a solutions:

Eg: Birthday : 1992/05/09
      Password : 199259 instead of 19920509

This is the code
 if( resultados != null && resultados.size() > 0){
          
            for(Account  result: resultados){
                    
                    result.Username__c = result.NIF__c;
                    result.Password__c = ''+result.PersonBirthdate.day() + result.PersonBirthdate.month() + result.PersonBirthdate.year();
            } 
        }

Thank u in advanced

Hello,
I am getting below Error when ever I am trying to use the below Syntax
"LREngine.Context ctx = new LREngine.Context(Parent_API.SobjectType, // parent object
                                                                               Child_API.SobjectType,  // child object
                                                                               Schema.SObjectType.Child.fields.Relationship_Field_API // relationship field name
    );
"

Error: Compile Error: Invalid type: LREngine.Context at line 18 column 32

Can you please help me fix this?
I tried in many blogs but I didnt receive any reply from others.

Thanks,
MR
 
  • January 26, 2015
  • Like
  • 0
Hi All ,

I am working on quote ,I want to generate the quote in the form of doc file .I want to remove the header from first page only .
Any help is highly appreciated
Well, all I can say is that it does add an account, and if you send it a blank string, it does return a NULL, so I am wondering what I did wrong. Here is the code:

public class AccountHandler {

    public static ID  insertNewAccount(String myStr) {
        try {
            Account acct = new Account(Name=myStr);
            insert acct;
            
            return(acct.id);
            
        } catch (DmlException e) {
            System.debug('A DML exception has occurred:' + e.getMessage());
            return(NULL);
        }
        
    }
            
}

Thanks in advance for the help,

Feeling dumb

Hey community,

I'm struggling with the logic of the task...

To complete this challenge, add a validation rule which will block the insertion of a contact if the contact is related to an account and has a mailing postal code (which has the API Name MailingPostalCode) different from the account's shipping postal code (which has the API Name ShippingPostalCode).Name the validation rule 'Contact must be in Account ZIP Code'.

A contact with a MailingPostalCode that has an account and does not match the associated Account ShippingPostalCode should return with a validation error and not be inserted.

The validation rule should ONLY apply to contact records with an associated account. Contact records with no associated parent account can be added with any MailingPostalCode value. (Hint: you can use the ISBLANK function for this check)

Here is what I got so far:

AND(
 NOT(ISBLANK(MailingPostalCode)),
 MailingPostalCode  <>  Account.ShippingPostalCode )

I THINK I know how to see if the contact mailing zip is not the same as the account shipping zip, and only if the is not blank.

The part I am stuck on is if the "Contact records with no associated parent account can be added with any MaiilingPostalCode value"...

I don't know what to do with that.

Also, I am now getting the error message when I recheck challenge:

Challenge not yet complete... here's what's wrong: 
There was an unexpected error in your org which is preventing this assessment check from completing: System.DmlException: Insert failed. First exception on row 0; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, Contact_must_be_in_Account_ZIP_Code: [] 


Double help, please.

This challenge seems simple enough but I'm stuck and any help would be appreciated. 

So the Challenge is Create a validation rule to check that a contact is in the zip code of its account. here is the question below:
To complete this challenge, add a validation rule which will block the insertion of a contact if the contact is related to an account and has a mailing postal code (which has the API Name MailingPostalCode) different from the account's shipping postal code (which has the API Name ShippingPostalCode).Name the validation rule 'Contact must be in Account ZIP Code'.
A contact with a MailingPostalCode that has an account and does not match the associated Account ShippingPostalCode should return with a validation error and not be inserted.
The validation rule should ONLY apply to contact records with an associated account. Contact records with no associated parent account (hint: you can use the ISBLANK function for this check) can be added with any MailingPostalCode value

Here is my  work.. Any help would be appreciated.. thanks, 

Rule Name Contact_must_be_in_Account_ZIP_Code Active [Checked]
Error Condition Formula AND( BillingPostalCode = ShippingPostalCode )
Error Message Billing zipcode does not match the Shipping Zipcode Error Location Billing Zip/Postal Code