• Abdulla d 5
  • NEWBIE
  • 25 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 22
    Replies
I have requirement to create a list view button on Accountcert object. That button just need to call the webservice  method. this is my requirement. 
that method need to pass parameters. how could i achieve this? this need to support in lightning as well
Hi all, i have requirement that , fieldset having three fields, while entering data into fieldset fields we need to check that field is null or not?
if it is null it must display some custom message?but not using validation rule how can i achieve it? how to get fieldset fields in apex to check th filed is not null?
I have requirement that i have object called request in this i have to select the Account name and populate the fields of name and shipping address into the custom object request? how can i achieve it.?

How to auto populate fields of Account to custom object Request__C when i select Account record as a lookup relation?
I have requirement to create a list view button on Accountcert object. That button just need to call the webservice  method. this is my requirement. 
that method need to pass parameters. how could i achieve this? this need to support in lightning as well

(TEXT(Full_Care_Confirmed__c)) == 'Yes'
&&
(
((ISPICKVAL(CPQ_Order_Type__c,'Corporate-Full Care Equipment Domestic'))
||
ISPICKVAL(CPQ_Order_Type__c,'Corporate-Full Care International')
||
ISPICKVAL(CPQ_Order_Type__c,'Corporate-Full Care Demo Equipment Accept')
||
ISPICKVAL(CPQ_Order_Type__c,'Canada-Full Care Equipment')))

IF full care confimed picklist field is set to YES then CPQ_Order_Type__c picklist value should be any of the above
public class ELOUpload_Class {
   
    public static void ELOUpload_Method1 (List<ContentDocument> lstContentDoc) {
      
       //Create a set of all the incoming IDs
        Set<Id> contDocId = new Set<Id> (); 
            
        for (ContentDocument contDoc : lstContentDoc ) {
            
           contDocId.add(contDoc.Id);
          
        }
        system.debug('contDocId = ' + contDocId );  
        
        List <ContentDocumentLink> contDoclink = [SELECT Id, ContentDocumentId FROM ContentDocumentLink WHERE ContentDocumentId = '0692O0000003CSTQA2']; 
        
        system.debug('contDoclink   = ' + contDoclink );      

    }
}
Hi Guys - I am working with ContentFiles and am trying to get a list to populate with some values from the ContentDocumentLink object. The code above (with hardcoded value) works fine and returns the values. However when trying to do it referencing the set variable (contDocId) in the code below I get no values returned. The contDocId is being pulled correctly too (which is the hardcoded value).
public class ELOUpload_Class {
   
    public static void ELOUpload_Method1 (List<ContentDocument> lstContentDoc) {
      
       //Create a set of all the incoming IDs
        Set<Id> contDocId = new Set<Id> (); 
            
        for (ContentDocument contDoc : lstContentDoc ) {
            
           contDocId.add(contDoc.Id);
          
        }
        system.debug('contDocId = ' + contDocId );  
        
        List <ContentDocumentLink> contDoclink = [SELECT Id, ContentDocumentId FROM ContentDocumentLink WHERE ContentDocumentId IN :contDocId]; 
        
        system.debug('contDoclink   = ' + contDoclink );      

    }
}
Now sure how to proceed? - many thanks for any assistance


 
Hi Everyone, 
I have this Apex code which takes the current date currency value when i ran batch, but now my client want to see when ever i ran btach it should take previous month currency value

So how where and how shouuld i change the code to accomplish below req and code. please someone help me modify my code. 

Every single day, financial exchange rates change according to the markets. So what we do, is instead of trying to grab the latest exchange rate every day, we wait until the previous month ends. Then we grab the average exchange rate for that previous month and inputted it into sfdc.
So in this example: We wait until February 2019 is done. Then come march 1st, 2019 we will be able to take the average exchange rate for the entire month of February 2019 and input it into sfdc.

This means that currently, for USD opportunities that close in February 2019, the exchnage rate for the month of January 2019  is used to do the conversion until we are able to go back and update our systems to include the month of february 2019 exchange rate.



This is my code :- 

public class ForexCurrencyHandler {
    
    public void processData () {
        ExchangeRate exchangeRate = (ExchangeRate) JSON.deserialize(callPublicExchangeRateApi(), ExchangeRate.class);
        // Need to populate date manually because we cannot use the "date" name as a variable since it's a reserved keyword
        exchangeRate.currencyDate = Date.today(); 
        
        String jsonDatedConversionRate = createDatedConversionRateJSON(exchangeRate);       
        insertDatedConversionRate(jsonDatedConversionRate);
    }    
    
    public String callPublicExchangeRateApi(){
        
        HttpRequest req = new HttpRequest();
        req.setEndpoint('https://api.exchangeratesapi.io/latest?base=CAD&symbols=USD');
        req.setMethod('GET');
        Http http = new Http();
        HTTPResponse res = http.send(req);
        System.debug('callout 1 '+res.getStatuscode());
        return res.getBody();
    }
        
    public String createDatedConversionRateJSON (ExchangeRate exchangeRate) {
        DatedConversionRate conversionRate = new DatedConversionRate();
        conversionRate.ConversionRate = exchangeRate.rates.get('USD');
        conversionRate.IsoCode = 'USD';
        conversionRate.StartDate = Date.today();
        system.debug(conversionRate);
        return JSON.serializePretty(conversionRate);
               
    }
    
    public void insertDatedConversionRate (String jsonDatedConversionRate) {
        Http h = new Http();
        HttpRequest req = new HttpRequest();
        req.setEndpoint(URL.getSalesforceBaseUrl().toExternalForm() + '/services/data/v44.0/sobjects/DatedConversionRate/');
        String body = jsonDatedConversionRate;
        req.setBody(body);
        req.setHeader('Authorization', 'OAuth ' + UserInfo.getSessionId());
        req.setHeader('Content-Type', 'application/json');
        req.setMethod('POST');
        HttpResponse res = h.send(req);
        
         System.debug('callout 2 '+res.getBody());
         System.debug('callout 2 '+res.getStatuscode());
    }
    
    
    public class ExchangeRate
    {
        public map<String,Decimal> rates;
        public String base;
        public Date currencyDate;
    }
    
    
    
}
Hello All,

I am currently having issues with allowing visitors to self-register in a lightning community portal. I have enabled "Person Accounts". Within in the site builder, I have the community configured to allow for self-registration and the profile is setup to the "Customer Community User Login" Profile. When I try to register I am receiving a error, "The error message is: portal account owner must have a role". I understand if I didn't have "Person Account" this would be fine because I can set that account with a user that has a role. The "Guest User" default for accounts is set to the "Person Account" record type, it is the only record type for that profile and it is the default RT. All of the files I am using are the ones that are created automatically when you create a custom community.  
Apex Controller:
global class LightningSelfRegisterController {

    public LightningSelfRegisterController() {

    }

    @TestVisible 
    private static boolean isValidPassword(String password, String confirmPassword) {
        return password == confirmPassword;
    }
    
    @TestVisible 
    private static boolean siteAsContainerEnabled(String communityUrl) {
        Auth.AuthConfiguration authConfig = new Auth.AuthConfiguration(communityUrl,'');
        return authConfig.isCommunityUsingSiteAsContainer();
    }
    
    @TestVisible 
    private static void validatePassword(User u, String password, String confirmPassword) {
        if(!Test.isRunningTest()) {
        Site.validatePassword(u, password, confirmPassword);
        }
        return;
    }
    
    @AuraEnabled
    public static String selfRegister(String firstname ,String lastname, String email, String password, String confirmPassword, String accountId, String regConfirmUrl, String extraFields, String startUrl, Boolean includePassword) {
        Savepoint sp = null;
        try {
            sp = Database.setSavepoint();
            
            if (lastname == null || String.isEmpty(lastname)) {
                return Label.Site.lastname_is_required;
            }
            
            if (email == null || String.isEmpty(email)) {
                return Label.Site.email_is_required;
            }
            
            User u = new User();
            u.Username = email;
            u.put('Email',email);
            
            u.FirstName = firstname;
            u.LastName = lastname;
            
            String networkId = Network.getNetworkId();

            // If using site to host the community the user should not hit s1 after logging in from mobile.
            if(networkId != null && siteAsContainerEnabled(Network.getLoginUrl(networkId))) {
                u.put('UserPreferencesHideS1BrowserUI',true);
            }
            
            String nickname = ((firstname != null && firstname.length() > 0) ? firstname.substring(0,1) : '' ) + lastname.substring(0,1);
            nickname += String.valueOf(Crypto.getRandomInteger()).substring(1,7);
            u.put('CommunityNickname', nickname);
                     
            if (extraFields != null) {
                List<Object> extraFieldsList = (List<Object>) JSON.deserializeUntyped(extraFields);        
                for (Object thisFieldObject : extraFieldsList) {
                    Map<String,Object> thisField = (Map<String,Object>) thisFieldObject;
                    Schema.SObjectField sof = Schema.SObjectType.User.fields.getMap().get((String) thisField.get('fieldPath'));
                    u.put(sof, thisField.get('value'));
                }
            }
                        
            if (includePassword) {    
                if (!isValidPassword(password, confirmPassword)) {
                    return Label.site.passwords_dont_match;
                }
             validatePassword(u, password, confirmPassword);
            }
            else {
                password = null;
            }
            
            // lastName is a required field on user, but if it isn't specified, we'll default it to the username
            String userId = Site.createExternalUser(u, accountId, password);
            // create a fake userId for test.
            if (Test.isRunningTest()) {
                userId = 'fakeUserId';           
            }
            if (userId != null) { 
                if (password != null && password.length() > 1) {
                    ApexPages.PageReference lgn = Site.login(email, password, startUrl);
                    if(!Test.isRunningTest()) {
                     aura.redirect(lgn);
                    }
                }
                else {
                    ApexPages.PageReference confirmRef = new PageReference(regConfirmUrl);
                    if(!Test.isRunningTest()) {
                    aura.redirect(confirmRef);
                   }

                }
            }
            return null;
        }
        catch (Exception ex) {
            Database.rollback(sp);
            return ex.getMessage();            
        }
    }
    
    @AuraEnabled
    public static List<Map<String,Object>> getExtraFields(String extraFieldsFieldSet) { 
        List<Map<String,Object>> extraFields = new List<Map<String,Object>>();
        Schema.FieldSet fieldSet = Schema.SObjectType.User.fieldSets.getMap().get(extraFieldsFieldSet);
        if(!Test.isRunningTest()) {
        if (fieldSet != null) {
            for (Schema.FieldSetMember f : fieldSet.getFields()) {
                Map<String, Object> fieldDetail = new Map<String, Object>();
                fieldDetail.put('dbRequired', f.getDBRequired());
                fieldDetail.put('fieldPath', f.getFieldPath());
                fieldDetail.put('label', f.getLabel());
                fieldDetail.put('required', f.getRequired());
                fieldDetail.put('type', f.getType());
                fieldDetail.put('value', '');   // client will populate
                extraFields.add(fieldDetail);
            }}}
        return extraFields;
    }
    
    @AuraEnabled
    global static String setExperienceId(String expId) {
        // Return null if there is no error, else it will return the error message 
        try {
            if (expId != null) {
                Site.setExperienceId(expId);   
            }
            return null; 
        } catch (Exception ex) {
            return ex.getMessage();            
        }        
    }  
}

Lighting Cmp:
<!-- add implements="forceCommunity:availableForAllPageTypes" to surface the component in community builder -->
<aura:component controller="LightningSelfRegisterController" implements="forceCommunity:availableForAllPageTypes" access="global">
    <aura:attribute name="accountId" type="String" required="false" description="accountId for creating the user. If not specified, it will create a PersonAccount if possible for B2C scenario. Or otherwise if it's in a community, the community's self-registration accountId will be used."/>
    <aura:attribute name="regConfirmUrl" type="String" required="true"/>
    <aura:attribute name="startUrl" type="String" required="false" description="The url you go to after a successful login" />
    <aura:attribute name="showError" type="Boolean" required="true" description="" default="false" access="private"/>
    <aura:attribute name="errorMessage" type="String" required="false" description="" access="private"/>
    <aura:attribute name="firstnameLabel" type="String" required="false" default="First Name"/>
    <aura:attribute name="lastnameLabel" type="String" required="false" default="Last Name"/>
    <aura:attribute name="emailLabel" type="String" required="false" default="Email"/>
    <aura:attribute name="passwordLabel" type="String" required="false" default="Create Password"/>
    <aura:attribute name="confirmPasswordLabel" type="String" required="false" default="Confirm Password"/>    
    <aura:attribute name="submitButtonLabel" type="String" required="false" default="Sign Up"/>
    <aura:attribute name="includePasswordField" type="Boolean" required="false" default="false" description="Whether to include password"/>    
    <aura:attribute name="extraFieldsFieldSet" type="String" required="false" description="A field set name whose fields are desired for user registration"/>
    <aura:attribute name="extraFields" type="list" required="false" description="A field set name whose fields are desired for user registration"/>
    <aura:handler name="init" value="{!this}" action="{!c.initialize}"/>
    <aura:attribute name="expid" type="String" required="false" description="The branding experience ID" />    
    
    <aura:registerevent name="sitePropagatedStartUrl" type="c:setStartUrl"/>
    <aura:handler name="init" value="{!this}" action="{!c.initialize}"/>
    <aura:dependency resource="c:setStartUrl" type="EVENT"/>
    
    <aura:dependency resource="siteforce:registerQueryEventMap" type="EVENT"/>
   
    <aura:handler event="c:setStartUrl" action="{!c.setStartUrl}"/> 
    <aura:handler event="c:setExpId" action="{!c.setExpId}"/>    
    <aura:dependency resource="c:setExpId" type="EVENT"/>   
    <ltng:require styles="{!$Resource.FontAwesomeWeb + '/fontawesome-web/css/all.css'}" />

   
    <div class="floating-container">
            <div class="register-container">
                <lightning:layoutItem padding="around-small" size="12" class="slds-align_absolute-center">
                    <div class="page-section page-header">
                        <img src="{!$Resource.starShadowOnly}" width="40" alt="city of chicago 311" />
                        <h1>Want to join us?</h1>
                        <p>Register a new account. Track all your requests </p>
                    </div>
                </lightning:layoutItem>
                <lightning:layoutItem size="12">
                <div id="sfdc_username_container" class="sfdc">
                    <!-- <span id="sfdc_user" class="login-icon" data-icon="a"></span> -->
                    <ui:inputText value="" aura:id="firstname" placeholder="{!v.firstnameLabel}" keyup="{!c.onKeyUp}" class="input sfdc_usernameinput sfdc"/>
                </div>
                </lightning:layoutItem>
                <lightning:layoutItem size="12">
                <div id="sfdc_nickname_container" class="sfdc">
                    <!-- <span id="sfdc_user" class="login-icon" data-icon="a"></span> -->
                    <ui:inputText value="" aura:id="lastname" placeholder="{!v.lastnameLabel}" keyup="{!c.onKeyUp}" class="input sfdc_usernameinput sfdc"/>
                </div>
                </lightning:layoutItem>
                <lightning:layoutItem size="12">
                <div id="sfdc_email_container" class="sfdc">
                    <!-- <span id="sfdc_user" class="login-icon" data-icon="k"></span> -->
                    <ui:inputText value="" aura:id="email" placeholder="{!v.emailLabel}" keyup="{!c.onKeyUp}" class="input sfdc_usernameinput sfdc"/>
                </div>
                </lightning:layoutItem>
                <aura:iteration aura:id="extraFields" items="{!v.extraFields}" var="curField" indexVar="index">
                    <div id="sfdc_extrafield_container" class="sfdc">
                        <!-- <span id="sfdc_user" class="login-icon" data-icon="a"></span> -->
                        <ui:inputText value="{!curField.value}" aura:id="{!curField.fieldPath}" placeholder="{!curField.label}" keyup="{!c.onKeyUp}" class="input sfdc_extrafieldinput sfdc"/>
                    </div>
                </aura:iteration>

                <aura:renderIf isTrue="{!v.includePasswordField}">
                    <div id="sfdc_password_container" class="sfdc">
                        <!-- <span id="sfdc_lock" class="login-icon sfdc" data-icon="c"></span> -->
                        <ui:inputSecret value="" aura:id="password" placeholder="{!v.passwordLabel}" keyup="{!c.onKeyUp}" class="input sfdc_passwordinput sfdc"/>
                    </div>
        
                    <div id="sfdc_confirm_password_container" class="sfdc">
                        <!-- <span id="sfdc_lock" class="login-icon sfdc" data-icon="c"></span> -->
                        <ui:inputSecret value="" aura:id="confirmPassword" placeholder="{!v.confirmPasswordLabel}" keyup="{!c.onKeyUp}" class="input sfdc_passwordinput sfdc"/>
                    </div>
                </aura:renderIf>
                <aura:renderIf isTrue="{!v.showError}">
                    <div id="error">
                        <ui:outputRichText value="{!v.errorMessage}"/>
                    </div>
                </aura:renderIf>

                <div class="sfdc">
                    <!-- <ui:button aura:id="submitButton" label="{!v.submitButtonLabel}" press="{!c.handleSelfRegister}" class="sfdc_button"/> -->
                    <lightning:button variant="brand" label="{!v.submitButtonLabel}" onclick="{!c.handleSelfRegister}" class="sfdc_button" />
                </div>
            </div>
    </div>
</aura:component>

Cmp Controller:
({
    initialize: function(component, event, helper) {
        $A.get("e.siteforce:registerQueryEventMap").setParams({"qsToEvent" : helper.qsToEventMap}).fire();
        $A.get("e.siteforce:registerQueryEventMap").setParams({"qsToEvent" : helper.qsToEventMap2}).fire();        
        component.set('v.extraFields', helper.getExtraFields(component, event, helper));
    },
    
    handleSelfRegister: function (component, event, helpler) {
        helpler.handleSelfRegister(component, event, helpler);
    },
    
    setStartUrl: function (component, event, helpler) {
        var startUrl = event.getParam('startURL');
        if(startUrl) {
            component.set("v.startUrl", startUrl);
        }
    },
    
    setExpId: function (component, event, helper) {
        var expId = event.getParam('expid');
        if (expId) {
            component.set("v.expid", expId);
        }
        helper.setBrandingCookie(component, event, helper);
    },
    
    onKeyUp: function(component, event, helpler){
        //checks for "enter" key
        if (event.getParam('keyCode')===13) {
            helpler.handleSelfRegister(component, event, helpler);
        }
    }   
})

Cmp Helper:
({
    qsToEventMap: {
        'startURL'  : 'e.c:setStartUrl'
    },
    
    qsToEventMap2: {
        'expid'  : 'e.c:setExpId'
    },
    
    handleSelfRegister: function (component, event, helpler) {
        var accountId = component.get("v.accountId");
        var regConfirmUrl = component.get("v.regConfirmUrl");
        var firstname = component.find("firstname").get("v.value");
        var lastname = component.find("lastname").get("v.value");
        var email = component.find("email").get("v.value");
        var includePassword = component.get("v.includePasswordField");
        var password = component.find("password").get("v.value");
        var confirmPassword = component.find("confirmPassword").get("v.value");
        var action = component.get("c.selfRegister");
        var extraFields = JSON.stringify(component.get("v.extraFields"));   // somehow apex controllers refuse to deal with list of maps
        var startUrl = component.get("v.startUrl");
        
        startUrl = decodeURIComponent(startUrl);
        
        action.setParams({firstname:firstname,lastname:lastname,email:email,
                password:password, confirmPassword:confirmPassword, accountId:accountId, regConfirmUrl:regConfirmUrl, extraFields:extraFields, startUrl:startUrl, includePassword:includePassword});
          action.setCallback(this, function(a){
          var rtnValue = a.getReturnValue();
          if (rtnValue !== null) {
             component.set("v.errorMessage",rtnValue);
             component.set("v.showError",true);
          }
       });
    $A.enqueueAction(action);
    },
    
    getExtraFields : function (component, event, helpler) {
        var action = component.get("c.getExtraFields");
        action.setParam("extraFieldsFieldSet", component.get("v.extraFieldsFieldSet"));
        action.setCallback(this, function(a){
        var rtnValue = a.getReturnValue();
            if (rtnValue !== null) {
                component.set('v.extraFields',rtnValue);
            }
        });
        $A.enqueueAction(action);
    },

    setBrandingCookie: function (component, event, helpler) {        
        var expId = component.get("v.expid");
        if (expId) {
            var action = component.get("c.setExperienceId");
            action.setParams({expId:expId});
            action.setCallback(this, function(a){ });
            $A.enqueueAction(action);
        }
    }    
})

 
Hi, I am not a developer. I need to write trigger on opportunity object,  opp name should be auto populate accountname:oppname entered by user.
requirement is
company has decided to have the Opportunity naming convention as “<Account Name>: <Opportunity Name>”. For example, if the opportunity is pertaining to 200 laptops, from Account ABC, the Opportunity naming convention should be “ABC: 200 laptops”. However, do not mandate this to be filled in as such by users. Instead, automatically update the Opportunity name as <Account Name>: <Opportunity Name> if someone creates the Opportunity without Account Name already in it.
Hi All,

I have formula field of text datatype. It used to captured QR code of each Campaign Member Record.
On VFPage it's working fine.
But on Render as PDF, it shows currepted image.

Following is the formula field :
QR Code :
IMAGE('https://chart.googleapis.com/chart?chs=150x150&cht=qr&chl=MECARD://tjt--aresssbox.cs64.my.salesforce.com/'&Id ,'Scan QR code to open record in mobile.')
Hi, I am having trouble with the "Attributes and Expressions" module from trailhead.

Here is the challenge:
Create a Lightning Component to display a single item for your packing list.
  • Create a component called campingListItem that displays the name (ui:outputText) and the three custom fields using the appropriate output components.
  • Add an attribute named 'item' for type Camping_Item__c.
I created an component named campingListItem and this is the code:
<aura:component >
    <aura:attribute name="item" type="<my_domain>__Camping_Item__c"/>
    
    <ui:outputText value="{!v.item.Name}"/>
    <ui:outputCheckbox value="{!v.item.<my_domain>__Packed__c}"/>
    <ui:outputCurrency  value="{!v.item.<my_domain>__Price__c}"/>
    <ui:outputNumber value="{!v.item.<my_domain>__Quantity__c}"/>
</aura:component>

The error that I am getting is: "Challenge Not yet complete... here's what's wrong: 
The packingListItem Lightning Component's attribute tag doesn't exist or its attributes are not set correctly."

With this, I tried to create another component, with the name "packingListItem", but It didn't work.

Can anyone help me?

Thanks,
hi gyus... This code is working fine..when ever I insert or update record it sends email.. but I am quite confused  so plz explain me the use of line 16,line 19,line 25 & what is the use of flag... and tell me that is messaging.singleEmailMessage is defined keyword...??
Last but not the least I want to edit the code in such a way that if i insert the data with dataloader where there is more than one contact then send email to more than one contact is inserted at a time....

************apex class**********
public with sharing class HelperContactTrigger {
    public static List<Contact> sendEmail(List<Contact>Contacts)
    {
     //query on template object
        EmailTemplate et=[Select id from EmailTemplate where name=:'Sales: New Customer Email'];

        //list of emails
        List<Messaging.SingleEmailMessage> emails = new List<Messaging.SingleEmailMessage>();   
        
        for(Contact con : Contacts)
        {
          //check for Account
            if(con.AccountId != null && con.Email != null){

                //initiallize messaging method
                Messaging.SingleEmailMessage singleMail = new Messaging.SingleEmailMessage();

                //set object Id
                singleMail.setTargetObjectId(con.Id);

                //set template Id
                singleMail.setTemplateId(et.Id);

                //flag to false to stop inserting activity history
                singleMail.setSaveAsActivity(false);

                //add mail
                emails.add(singleMail);
            }
        }
            //send mail
        Messaging.sendEmail(emails);

        return Contacts;          
        
    }

    public static List<Contact> sendEmailafter(List<Contact>Contacts)
    {
    //query on template object
        EmailTemplate et=[Select id from EmailTemplate where name=:'Sales: New Customer Email'];

        //list of emails
        List<Messaging.SingleEmailMessage> emails = new List<Messaging.SingleEmailMessage>();   
        
        for(Contact con : Contacts)
        {
          //check for Account
            if(con.AccountId != null && con.Email != null){

                //initiallize messaging method
                Messaging.SingleEmailMessage singleMail = new Messaging.SingleEmailMessage();

                //set object Id
                singleMail.setTargetObjectId(con.Id);

                //set template Id
                singleMail.setTemplateId(et.Id);

                //flag to false to stop inserting activity history
                singleMail.setSaveAsActivity(false);

                //add mail
                emails.add(singleMail);
            }
         }
            //send mail
        Messaging.sendEmail(emails);

        return Contacts;          
        }
    }

*********Apex trigger********
trigger SendEmailToAccount on Contact (after insert,after update) 
{
    if(Trigger.isAfter)
    {
        if(Trigger.isInsert )
        { 
            //helper class for single email but bulk messages
            HelperContactTrigger.sendEmail(trigger.new);
        }
    }
        if(trigger.isAfter && trigger.isUpdate )
        {           
         HelperContactTrigger.sendEmailafter(trigger.new);
        }
}

 

Hi,

 

I am trying to find how to locate the 15-digit Salesforce ID of a given custom object. I need this to dynamically create a record type selection link:

 

/setup/ui/recordtypeselect.jsp?ent= <Salesforce_ID_Of_Custom_Object>

 

For standard objects its fine to simply enter the object name in the 'ent' parameter, but for custom objects it requires the Salesforce ID (which is the one you find if you look at the URL when editing that particular object. I understand getKeyPrefix() within the DescribeResult gives you the first three digits but there does not seem to be a way of getting the entire 15-digit ID. 

 

Hope someone can help me out. 

Hi,

 

Is there a way to get the namespace prefix of the organization in apex?  

 

Thanks in advance.

 

Regards,

Dipak

  • September 14, 2012
  • Like
  • 0

Hi all,

 

I'm passing some tests on freelance sites. On one of them I faced with question:

"Which type of apps are built using only the Force.com API to access the Salesforce service?"

And the answers:

"

a. Composite apps

b. Client apps

c. Native apps

d. All of the above

"

 

Can you point me where to find answer on this question? Or maybe someone explaines me what this question mean.

  • November 10, 2011
  • Like
  • 0

Hi All,

 

I am new to Saleforce development. Please can any one guide me to sample apex code to create(add) custom fields to custom or standard objects dynamically using Salesforce Metadata API in my development org.

 

Thanks in advance.

  • June 29, 2011
  • Like
  • 0
Hi All, I wanted to retrieve Salesforce Id of a field in Apex code. Any Idea? Thanks
  • December 03, 2010
  • Like
  • 0

Hi:

I am trying to save a Google chart (PNG file) that I am displaying with a formula as an  attachment to my sObject. Its working fine as a HTML file, but I like to save the actual png file instead. Here is what I have:

 

my formula field DemoImage2:

 

IMAGE("http://chart.apis.google.com/chart?chs=250x100&chd=t:60,40&cht=p3&chl=Hello|World", "DemoImage2")

 

apex code:

 

Attachment a = new Attachment( parentId = chgCotr.id, name=chgCotr.Name+'.html', body = Blob.valueof(chgCotr.DemoImage2__c ); Database.insert(a);

 




 

produces an html attachment with the following markup:

 

<img src="http://chart.apis.google.com/chart?chs=250x100&amp;chd=t:60,40&amp;cht=p3&amp;chl=Hello|World" alt="DemoImage2" border="0"/>

 

What I want to save is the source image as png file instead of the <img>markup.

 

How can I get this accomplished?

 

Thanks in advance for your suggestions.

 

Matt