• Sourav P
  • NEWBIE
  • 390 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 9
    Likes Given
  • 100
    Questions
  • 212
    Replies
Dear All,

I am not able to install the package from the provided link, showing below error. May i know plz how to install it? Thanks
User-added image
Hi
If anyone can describe me the definition of " Namespace" in simple terms to understand. i tried to refer the apex developer guide but not able to understand properly, Thanks

User-added image
Hi,
I want a certain profile users to block changing the Time zone and Locale field on their below set up, Can anybody plz suggest me to write a trigger to do so?
User-added image
 
Hi, Bulk update is done on a custom object via supported application (Heroku). On check of flag in this custom object, there is a after update trigger that gets fired to auto approve the record.
When we update 100 records the trigger is fired only for 5 records.
what can be the issue ?
Hi,

In the below link, SF has provided the formula, althouth i am familiar with the CASE, MOD functions, i am not able to understand why its been divided by 7, and rest details within formula. also at last why to multiply by 5 .
Also, Initially, why its minus the ref date from start date ? and if the divided value is 0,1,2 etc why again its dividing by 7, and if its 1, value taken 2, if its 2, values taken 3 etc ?
If anybody can able to make me understnd the formula why its so ? Thanks
https://help.salesforce.com/articleView?id=000004526&type=1
 
Weekday Count Formula:

CASE(MOD( StartDate__c - DATE(1985,6,24),7), 
  0 , CASE( MOD( EndDate__c - StartDate__c ,7),1,2,2,3,3,4,4,5,5,5,6,5,1), 
  1 , CASE( MOD( EndDate__c - StartDate__c ,7),1,2,2,3,3,4,4,4,5,4,6,5,1), 
  2 , CASE( MOD( EndDate__c - StartDate__c ,7),1,2,2,3,3,3,4,3,5,4,6,5,1), 
  3 , CASE( MOD( EndDate__c - StartDate__c ,7),1,2,2,2,3,2,4,3,5,4,6,5,1), 
  4 , CASE( MOD( EndDate__c - StartDate__c ,7),1,1,2,1,3,2,4,3,5,4,6,5,1), 
  5 , CASE( MOD( EndDate__c - StartDate__c ,7),1,0,2,1,3,2,4,3,5,4,6,5,0), 
  6 , CASE( MOD( EndDate__c - StartDate__c ,7),1,1,2,2,3,3,4,4,5,5,6,5,0), 
  999) 
  + 
  (FLOOR(( EndDate__c - StartDate__c )/7)*5)

 
Hi,
I have a task againg field , formula as below ( type " number")
LastModifiedDate - CreatedDate
But i want to exclude the sat-sun and a public holiday list from this number. May i know how to modify the formula ? thnx
 
Hi,
I have a profile, which should able to merge accounts. But They shouldn't manually delete any accounts. Although the delete button in the account has been removed, in the list view its till visible.
can anyone, help me with a trigger , that while they delete, it should through an error message but while merging there shoulnt be an issue. Thanks
Hi,
Its a simple WF rule but Seems a bit complex for me to understand below, while it seems everything is perfect. Can anyone plz make  me understand whats wrong here? Thnx

- Created a WF rule in Quote object, which in turn do a checkbox field update in teh same quote object to TRUE.

Logic is : If the Activated time of the contract object is > 4.30 PM ( We have 24 hr format showing in UI & the contract is generated after going through the payment process of the Quote)
( As of now made it <16, to test at present)
 
IF(VALUE(MID(TEXT(Contract.ActivatedDate+(7/24)), 12, 2)) < 16, true, 
If( VALUE(MID(TEXT(Contract.ActivatedDate+(7/24)), 12, 2)) = 16, 
IF(VALUE(MID(TEXT(Contract.ActivatedDate+(7/24)), 15, 2)) > 30, true, false),false))
Evaluation Criteria : Evaluate the rule when a record is created, and any time it's edited to subsequently meet criteria

Field Update :
User-added image

But the issue is , it not working and not updating the field to TRUE.

But the i have used teh same formula above in a formula field created in teh Quote object ( checkbox), and its working fine with the contract activated time.
So , May i know why not the simple WF rule is working here ? Thnx 
 
Hi,
I have created a PB in Quote object, included a logic followed by a " Scheduled Actions" as,
Create Record : 15 days before start date ( start date of Quote),

As , its going to create a record in a past date, How does its going to work ?
- Does it create a record & put the created date as today ? ( within an hour ? Or immediately)

I tested but actually no records been get created. Can anyone plz suggest,where i went wrong ? Thnx 

User-added image
User-added image
Hi, 
I have a simple WF rule created in Quote object, as below, It seems everything OK, But its not triggering to update a checkbox field to TRUE. Can anyone plz suggest where i went wrong or whats the issue  ? Thnx

WF Rule ( 3 rd option : Evaluate the rule when a record is created, and any time it's edited to subsequently meet criteria)

Logic : It should update a checkbox field in Quote to TRUE if the Contract activated time is greater than 16.30 ( we have 24 hr format)

IF(VALUE(MID(TEXT(Contract.ActivatedDate+(7/24)), 12, 2)) >16, true, If( VALUE(MID(TEXT(Contract.ActivatedDate+(7/24)), 12, 2)) = 16, IF(VALUE(MID(TEXT(Contract.ActivatedDate+(7/24)), 15, 2)) > 30, true, false), false ))

Field updation as below,

User-added image


 
Hi,
I have a wf rule where, contract activated field ( date/time) need to be less than the local time 16.30 ( 24 hr format). I am trying the below, but i have the issue in comparing the minutes,
My formula as below,

AND( IF(VALUE(MID(TEXT(Contract.ActivatedDate+(7/24)), 12, 2)) > 16, true, false),IF(VALUE(MID(TEXT(Contract.ActivatedDate+(7/24)), 15, 2)) > 30, true, false) )

Now, Hour is OK, but certainly i cant put AND for minutes neither OR. As 17.20 is also greater than 16.30, So anyone plz suggest how can i modify teh above formula to include the minute one ? Thanks
 
Hi,
I have created the below tasks as scheduled actions under the Contract object, criteria is when the OP >0,
Now i want to autoclose the tasks under the criteria as,
- Trigger criteria not met anymore, or new payment failure task created
i.e when the OP <0  OR if "Notification " one is Open, and the "Final reminder" one get created then the " Notification" one should get closed. I couldnt determine how to do teh second part. Can you plz suggest.
Can i create this in teh same PB of task creation? ( The criteria is OP >0, then its creating the tasks on regular intervals).
Or Do i need to create another PB in any othr object ( Task ?). Thanks

User-added image
Hi,
For a formula field where the outcome is date, in the report i am getting the below error,

Error running your report:
One of the date fields in your report was invalid. Check your records and formulas for errors. They may contain or produce non-existent dates, like February 30, or ones that are out of bounds. Edit this report and click <b>Remove All Columns</b> to start over.


Seems , the date formula is generating some invalid dates. How can i fix it ?
My formula below is like this,
 
(Currency_c /
Currency1__c)*(IF(TEXT(Type__c)="Cancellation",Date__c,Date1__c) - Date2__c)+ Date2__c



Where , Currency & Currency1__c are formula(currency) fields.

 
Hi,
I have created a task on the object Contract. There are same task types with different criterias, what i want is that if one of the same task type has a status as " Open", in the object Contract, It shouldnt generate another same type of task. I have " Type" as a picklist in the task.
May be for that it seems i need a task type counter field in the contract object ( how to do that ? ) which i can use in the PB logic or how to do that in any other way ? Thanks
Hi,
I want particular tasks to assign a group of people, similar to a Task assigned to a queue, But as this feature is till an idea and not implemented yet, I want to know if through apex code we can achieve this ?

I can use Roles, personal, public groups, multiple users But these are not satisfying my requirement as, those creating multiple same tasks for each assigned users, I want that only one task should be reflecteed in a particular object. and from a group of users anybody can pick it up. Any suggestions plz, on how to write a coding for this. Thanks

Hi,
I have a custom object, with one checkbox field as "Record Used". I want to know that if the remaining Record Used with checkbox not ticked ( false) less than or equal to 500, it should send us the alert, so that we can add more records to be used .
I tried to create it through VisualFlows, and later called it through the PB, But It seems i am not able to create a proper flows, can anyone plz modify me, where i need to add elements. I as well need to send email to specific people if it reached 500.
Below is my VF screenshots,

I used ,

1. Fast lookup element - To fetch all object Records
2. Loop element - To loop through all object records
3. Assignment element - To assign the potential value to a variable and find the count.
4. Record Update element - To update all object records with the total count.

1.
User-added image
2.
User-added image
3.
User-added image
4.
User-added image
5.
User-added image
Hi,
I have a custom object, with one checkbox field as "Record Used". I want to know that if the remaining Record Used with checkbox not ticked ( false) become less than or equal to 100, it should send us the email alert, so that we can add more records to be used .
I am trying to create a formula field for this but i think its not going to work, can anyone plz suggest me a solution for this ? its within the same object and there is no cross object involved.Thnx
,
Hi,
I have the below report requirement,
- Below is the ways my objects are related , which have taken in teh report.
"Contract" is related to "Claim",
Claim to Damage
Damage to Payment 

Now , i want a report of the records, where the Payment in Damage object is not present. I tried the below filter but its not giving the proper result, If anyone suggest plz, where i went wrong. Thnx

User-added image
Dear All
Do we have any ways or Can we write an apex code, that i can extract the fields of an object, and where its been used, if on PB, WF, apex code etc.
 
Now if i want to know where a field been used,  have to take teh risk of delete it, so that it will show the dependencies of that field. If there is none, it get deleted. So, if i can get the list easier for me to decide which fields are not in use and can delete it. Thanks
Hi,
I have a custom object, where i have created a time based WF.  I have created Tasks on the WF. Now i want to assign those tasks only to some spefic  3 or 4 users.
The object is a child object in a MD relationship, so i dont have the option for creating a queue. Only options i can see in " Assigned to" filter is owner, user and role. I dont want to create a role for this one. If i choose user, it can have only one that i can select.
Is there any other way or if i can do through trigger , that i can assign the tasks in this object to these users only ? If trigger, Can you plz suggest the structure of the trigger.Thanks
Hi, Can anyone help me out with this,
User-added image
This is from a custom object " Quotation", The look up field " Main Driver" is a look up to Personal account object. The below fields are as well exists in the personal account. I need whatever value would be choosen in the main driver, automatically the below values will get pop up on below fields. I need to write a trigger for this ( I cant use formula field, as its depends upon another criteria field, so somtimes the user need to enter values manually in these fields , Process builder also doesnt worked).
I tried to write a trigger, but its not working , showing issue as " Error: Compile Error: IN operator must be used with an iterable expression at line 12 column 104 " Can anyone plz rectify my trigger to make it work. Thnx .( I just have taken two fields below for test)


trigger MainDriverRelatedFields on Quotation__c (before insert,before update) {

Quotation__c newQuote=new Quotation__c();
 
for(Quotation__c obj : Trigger.new){
newQuote=obj ;
    }
    List<Account> Acc= [SELECT id,Age__c, Acccidents_in_the_last_12_mnths__c FROM Account WHERE Id IN: newQuote.Main_Driver__r];
     if(newQuote.Main_Driver__c!=null) {
            newQuote.AgeMainD__c=Acc.Age__c;

            newQuote.Accidents_in_the_last_12_mnthsMainD__c= Acc.Acccidents_in_the_last_12_mnths__c;

        }
}




 
Hi
If anyone can describe me the definition of " Namespace" in simple terms to understand. i tried to refer the apex developer guide but not able to understand properly, Thanks

User-added image
Hi,
I want a certain profile users to block changing the Time zone and Locale field on their below set up, Can anybody plz suggest me to write a trigger to do so?
User-added image
 
Hi, Bulk update is done on a custom object via supported application (Heroku). On check of flag in this custom object, there is a after update trigger that gets fired to auto approve the record.
When we update 100 records the trigger is fired only for 5 records.
what can be the issue ?
Hi,
I have a profile, which should able to merge accounts. But They shouldn't manually delete any accounts. Although the delete button in the account has been removed, in the list view its till visible.
can anyone, help me with a trigger , that while they delete, it should through an error message but while merging there shoulnt be an issue. Thanks
Hi,
I have created a PB in Quote object, included a logic followed by a " Scheduled Actions" as,
Create Record : 15 days before start date ( start date of Quote),

As , its going to create a record in a past date, How does its going to work ?
- Does it create a record & put the created date as today ? ( within an hour ? Or immediately)

I tested but actually no records been get created. Can anyone plz suggest,where i went wrong ? Thnx 

User-added image
User-added image
I am new to development and can someone help to write trigger for the senario:

whenever a new guest is created (custom object Event Guest) trigger should find if there is an existing lead or contact, if any exists it should add lead/contact to campaign otherwise create a new lead and add to campaign. Campaign is find this way Event Guest->Event->Campaign.

trigger NewGuest on Event_Guests__c(after insert){
    for(Event_Guests__c myGuest : Trigger.New) {
        List<Lead> exLead = [SELECT Id FROM Lead WHERE Email = :myGuest.Guest_Email__c];
            if (exLead.size() == 0)
                {
                    List<Contact> exContact = [SELECT Id FROM Contact WHERE Email = :myGuest.Guest_Email__c];
                    if(exContact.size() == 0)
                        {
                            Lead newLead = new Lead();
                            newLead.FirstName = myGuest.Name;
                            newLead.LastName = myGuest.Last_Name__c;
                            newLead.Phone = myGuest.Guest_Phone__c;
                            newLead.Email = myGuest.Guest_Email__c;
                            newLead.LeadSource = 'Workshop Guest';
                            insert newLead;
                    
                            Campaignmember newMember = new Campaignmember();
                            newMember.LeadId = newLead.id;
                            newMember.dc__Registered_First_Name__c = myGuest.Name;
                            newMember.dc__Registered_Last_Name__c = myGuest.Last_Name__c;
                            newMember.dc__Registered_Email__c = myGuest.Guest_Email__c;
                            newMember.dc__Registered_Phone__c = myGuest.Guest_Phone__c;
                            newMember.Campaign = [SELECT dc__Event_Campaign__c FROM dc__Event__c WHERE Id = :myGuest.Event__c];
                            insert newMember;
                        }
                    else
                        {
                            Campaignmember newMember = new Campaignmember();
                            newMember.Contact = exContact.Id;
                            newMember.dc__Registered_First_Name__c = myGuest.Name;
                            newMember.dc__Registered_Last_Name__c = myGuest.Last_Name__c;
                            newMember.dc__Registered_Email__c = myGuest.Guest_Email__c;
                            newMember.dc__Registered_Phone__c = myGuest.Guest_Phone__c;
                            newMember.Campaign = [SELECT dc__Event_Campaign__c FROM dc__Event__c WHERE Id = :myGuest.Event__c];
                            insert newMember;
                        }               
                    
                }               
            if (exLead.size() != 0)
                {
                    Campaignmember newMember = new Campaignmember();
                    newMember.Lead = exLead.Id;
                    newMember.dc__Registered_First_Name__c = myGuest.Name;
                    newMember.dc__Registered_Last_Name__c = myGuest.Last_Name__c;
                    newMember.dc__Registered_Email__c = myGuest.Guest_Email__c;
                    newMember.dc__Registered_Phone__c = myGuest.Guest_Phone__c;
                    newMember.Campaign = [SELECT dc__Event_Campaign__c FROM dc__Event__c WHERE Id = :myGuest.Event__c];
                    insert newMember;
                }
                
            }
    }
Hi, 

 I have a trigger and a helper class created need a suggestion on how to create a test class for below
trigger RenwalQuote on QuoteLineItem (After Insert, After Update, Before Delete) {
 
 public static Boolean bool = true;
 Set<Id> setid = new Set<id>();
 List<QuoteLineItem> listoli = new  List<QuoteLineItem> ();
 List< OpportunitylineItem> lisopt = new  List< OpportunitylineItem > ();
 List< OpportunitylineItem> Dellisopt = new  List< OpportunitylineItem > ();
 set<id> setoppid = new set<id>();
 set<string> setprodcode = new set<string>();
 set<string> setrecordtype = new set<string>();
 Set<Id> setoldid = new Set<id>();
    
  if(trigger.isafter){
      
   If(preventRecursive.runOnce)return;
   if(bool){
      bool = false;
 
      for (QuoteLineItem qtl :  Trigger.new){
         setid.add(qtl.id);
        }
   } 
 
   List<QuoteLineItem> listem = [Select id,quoteid,Prior_Discount__c,product2.productcode,quote.opportunityid,
                                        quote.opportunity.recordtype.name                   
                                 from QuoteLineItem where id In : Setid];
   
   for(QuoteLineItem qlt:listem){
       
         if ( qlt.quote.opportunity.recordtype.name == 'Renewal Opportunity'){
          qlt.Prior_Discount__c = RenewalUtils.OppLineDisc(qlt.quote.opportunityid,qlt.quoteid,qlt.product2.productcode);
          qlt.Opportunity_Line_Item_ID__c = RenewalUtils.OppLineID(qlt.quote.opportunityid,qlt.quoteid,qlt.product2.productcode);
          system.debug('Quote ID' + qlt.quoteid);
          system.debug('qlt.product2.productcode' + qlt.product2.productcode);
          system.debug('Discount Value' + RenewalUtils.OppLineDisc(qlt.quote.opportunityid,qlt.quoteid,qlt.product2.productcode));
          listoli.add(qlt);
          setoppid.add(qlt.quote.opportunityid);
          setprodcode.add(qlt.product2.productcode);
         }
      } 
       
        if (!listoli.isEmpty()){
          preventRecursive.runOnce = true; update listoli;
                                     
         Opportunity Opp = [select id, Prior_Year_Opportunity__c from Opportunity where id = :setoppid];                                   
                                            
         List<OpportunityLineItem> PrilisOpp = [select id, Renewed__c, opportunity.Prior_Year_Opportunity__c 
                                                from OpportunityLineItem 
                                                where opportunityid = :Opp.Prior_Year_Opportunity__c and 
                                                      product2.productcode = :setprodcode ]; 
        
          for(OpportunitylineItem Opln : PrilisOpp){
              Opln.Renewed__c = true;
              lisopt.add(Opln);
         }
   
           if (!lisopt.isEmpty()){
              update lisopt;
            }  
  
       }
   }    
   
      if(Trigger.isbefore){
      
         for (QuoteLineItem qtl :  Trigger.old){
                setoldid.add(qtl.id);
          }
         
        QuoteLineItem oldQli = [select id, Opportunity_Line_Item_ID__c from QuoteLineItem where id = :setoldid];  
        List<OpportunityLineItem> LstOppline =  [select id, Renewed__c from OpportunityLineItem where id = : oldQli.Opportunity_Line_Item_ID__c];
              
          for(OpportunitylineItem DOpln : LstOppline){
            DOpln.Renewed__c = false;
            Dellisopt.add(DOpln);
          }
          
         if (! Dellisopt.isEmpty()){
                 update Dellisopt;
                }  
        
        
      }
      
}

Helper Class
public with sharing class RenewalUtils {

 public static String OppLineDisc(String QOppID, String Quoteid, String ProdCode) {
 
   Decimal Disctot;
   
   Opportunity ropp = [select Prior_Year_Opportunity__c from opportunity where id = :QOppID and recordtype.name = 'Renewal Opportunity']; 
 
   List<AggregateResult>  Opplst = [select avg(Discount_Percent__c) totdisc
                                    from OpportunityLineItem 
                                    where Opportunityid = :ropp.Prior_Year_Opportunity__c and 
                                          product2.productcode = :ProdCode 
                                          ];
                           
   for (AggregateResult arOpplst : Opplst)
     {
       Disctot = ((Decimal)arOpplst.get('totdisc'));
       
     }                                              
                        
     system.debug(Disctot);
                                              
      return string.valueof(Disctot);
 
 }
 
 
public static String OppLineID(String QOppID, String Quoteid, String ProdCode) {
 
   
   Opportunity ropp = [select Prior_Year_Opportunity__c from opportunity where id = :QOppID and recordtype.name = 'Renewal Opportunity']; 
 
   OpportunityLineItem  Opplst = [select id
                                    from OpportunityLineItem 
                                    where Opportunityid = :ropp.Prior_Year_Opportunity__c and 
                                          product2.productcode = :ProdCode limit 1
                                          ];
                    
     system.debug(Opplst.id);
                                              
      return string.valueof(Opplst.id);
 
 } 
 
}

Recurssive class
public class preventRecursive{
    public static Boolean runOnce = false;
}

Thanks
Sudhir
  • February 28, 2017
  • Like
  • 1
Experts, I am generating a report using conga composer manually on daily basis. It is giving the report in .pdf format. Is there any way to automate the process ? I want to store the .pdf report in my computers.

Thanks,
Ram
Hi all.

here is my code . how can i achieve 100% code coverage for this Trigger?



trigger CopyAttachments on SVMXC__Service_Order__c(after insert)
{
 //Attachment[] attList = [select id, name, body from Attachment where ParentId = :Trigger.new[0].SVMXC__Case__c];
 Attachment[] insertAttList = new Attachment[]{};
 
         for(Attachment a: [select id, name, body from Attachment where ParentId = :Trigger.new[0].SVMXC__Case__c])
         {
               Attachment att = new Attachment(name = a.name, body = a.body, parentid = Trigger.new[0].id);
               insertAttList.add(att);
         }
       if(insertAttList.size() > 0)
       {
            insert insertAttList;
       }
 
}
  • November 16, 2016
  • Like
  • 1
Hi everybody,

I have a mobile application Salesforce, in the user details's page, there is an SMS boutton, when I click on, I have to choose a template (Text body) and click Send .
The button have to send me to my mobile' SMS section with the choosed the template.
I'm stuck in the last step . How can i get from a mobile salesforce to SMS section ?

It works great with email and seletion templates too. So I just changed some paramettres as [Email = account.PersonEmail ;] by [Email = account.PersonMobilePhone ;]

VF page IC_GenerateSMS

<apex:page showHeader="false" docType="html-5.0" standardStylesheets="false" cache="false" Controller="IC_GenerateSMS_VFCx">
<html>
<head>
<title>{!$Label.IC_GenerateSMS}</title> 
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />

<link rel="stylesheet" href="{!URLFOR($Resource.JQuery_120, 'jquery.mobile-1.2.0.min.css')}" />
<apex:includeScript value="{!URLFOR($Resource.JQuery_120, 'jquery-1.8.2.min.js')}"/>
<apex:includeScript value="{!URLFOR($Resource.JQuery_120, 'jquery.mobile-1.2.0.min.js')}"/>   

<!-- New Relic integration -->
<apex:includeScript value="{!IF($Setup.ICONSettings__c.NewRelic__c, $Resource.NewRelic, '')}"/>

<script>
    $j = jQuery.noConflict();
    var backUrl = '/apex/IC_ClientDetails?id={!accountId}';
    
    function logTask(subject) {
        console.log('Selected Template ' + subject);
        IC_GenerateSMS_VFCx.createTask('{!accountId}','{!Email}',subject,
                                          function(records, e) {console.log(records);}, {escape:true});
    }
    
    function createMail(){
        
        logTask(document.getElementById("initSubject").innerHTML);
        var email = document.getElementById("Email").innerHTML;
        var subject = encodeURIComponent(document.getElementById("initSubject").innerHTML);
        var body = encodeURIComponent(document.getElementById("initBody").innerHTML);
        window.location = "mailto:"+email+"?subject="+subject+"&body="+body;
    }
</script>    
</head>
<body>
    <!-- EMAIL TEMPLATE PREVIEW AND SELECTION -->
    <div data-role="page" data-theme="a" id="mainpage" data-fullscreen="true" data-add-back-btn="true">
        <!-- HEADER -->
        <div data-role="header">
            <a href="#" onclick="window.location.href=backUrl;" data-icon='arrow-l' style="box-shadow: none;" data-iconshadow="false" data-iconpos="notext"></a>
            <h1>{!$Label.IC_ChooseTemplate}</h1>
        </div>
        <!-- CONTENT -->
    <div data-role="content" data-fullscreen="true">   
       <ul data-role="listview" data-theme="a"  data-inset="true" >
           <li>
           <div>
            <!-- SMS TEMPLATE SELECTION FORM -->
            <apex:form >
             <!-- SMS TEMPLATE SELECTION LIST -->
             <center>
             <div data-role="fieldcontain">
                <label for="selectedTemplate">{!$Label.IC_SelectTemplate}</label>   
                <apex:selectList value="{!selectedTemplate}"  size="1" id="selectedTemplate">
                    <apex:selectOptions value="{!templateOptions}"/>
                    <apex:actionSupport event="onchange" action="{!previewTemplate}" rerender="counter"/>
                </apex:selectList>
             </div>  
             </center> 
                <!-- SMS TEMPLATE SELECTION PREVIEW -->
                <apex:outputpanel id="counter">
                    <!-- SMS TEMPLATE ENCODED FOR BROWSER PREVIEW -->          
                    <!-- <div id="Email">{!Email}</div>  -->
                    <br/>
                    <div id="Subject"></div>
                    <br/>
                    <div id="Body"></div>
                    <!-- SMS TEMPLATE ENCODED FOR MOBILE MAIL SYSTEM -->
                    <div id="initSubject" style="display:none;visbility:hidden;">{!initSubject}</div> 
                    <div id="initBody" style="display:none;visbility:hidden;">{!initBody}</div> 
                    <script>
                        document.getElementById("Subject").innerHTML = "{!Subject}";
                        document.getElementById("Body").innerHTML = "{!Body}";
                    </script>      
                </apex:outputpanel>
            </apex:form>
            <br/>
            <!-- BUTTON TO GENERATE SMS IN MOBILE MAIL SYSTEM -->
            <a data-role="button" data-direction="reverse" data-transition="none" href="javascript:createMail();" data-icon="false" data-iconpos="left">
                {!$Label.IC_GenerateSMS}
            </a>
            </div>
          </li>
          </ul>
        </div>
    </div>
</body>
</html>
</apex:page>


IC_GenerateSMS_VFCx Controller

public with sharing class IC_GenerateSMS_VFCx {
 /** Variable declarations **/
    public String accountId{get;set;}
    public String ownerId;
    private Account account;
    private User owner;
    private User Sender;
    //public String SMS{get;set;}
    public String Email{get;set;}
    public String Subject{get;set;}
    public String initBody{get;set;}
    public String initSubject{get;set;}
    public String Body{get;set;}
    private List<EmailTemplate> emailtemplates;
    private List<SelectOption> tempList = new List<SelectOption>();
    private EmailTemplate emailTemplate;
    public string selectedTemplate{get;set;}
    
    public IC_GenerateSMS_VFCx() {
        /** Retrieve sms templates dedicated to mobile device **/
        List<Folder> Folders = [Select Id, Name From Folder Where Type = 'Email' AND DeveloperName like  '%Mobile'];
        emailtemplates = [select Id,Name,Subject,body,IsActive from EmailTemplate Where Folder.Id IN :Folders AND IsActive = true  Order By Folder.Name, Name Limit 1 ];
        tempList.add(new SelectOption('NONE', '----- ' + Label.IC_None +' -----'));
        for (EmailTemplate emailTemp : emailtemplates) {
            tempList.add(new SelectOption(emailTemp.id, emailTemp.Name));
        }
        /** Retrieve current account and owner information **/
        accountId = ApexPages.currentPage().getParameters().get('id');
        //account = [select id, Salutation, FirstName, LastName, PersonEmail, OwnerId from Account where id =: accountId];
        account = IC_Factory.getAccountt(accountId);
        //Email = account.PersonEmail;
        Email = account.PersonMobilePhone;
        //owner = [select id, FirstName, LastName from User where id = :account.OwnerId];
        //Sender = [select id, defaultStore__c from User where id =: UserInfo.getUserId()];
        owner = IC_Factory.getUser(account.OwnerId);
        Sender = IC_Factory.getUser(userInfo.getUserId());
    }
    
    /** Provide options for email template list **/
    public List<SelectOption> getTemplateOptions() {
        return tempList;
    }
        
    /** Encode and provide email template content **/
    public PageReference previewTemplate(){
        if(selectedTemplate <> 'NONE'){
            emailTemplate = [select Id,Name,Subject,Body from EmailTemplate where Id =: selectedTemplate LIMIT 1];
            Subject = renderMergeFieldsAndReplaceEncoding(emailTemplate.Subject);
            Body = renderMergeFieldsAndReplaceEncoding(emailTemplate.Body);
            initSubject = renderMergeFields(emailTemplate.Subject);
            initBody = renderMergeFields(emailTemplate.Body);
        }else{
            Subject = '';
            Body = '';
            initSubject = '';
            initBody = '';
        }
        return null;
    }
    
    private String nullToText(String value) {
        return (value == null?'':value);
    }
    
    private String nullToText_Title(String value) {
        return IC_UTILS.getTranslationPicklistValue('Contact', 'Salutation', value);
    }
    
    private String nullToText_Salutation(String value) {
        return IC_UTILS.getTranslationPicklistValue('Contact', 'Salutation', value);
    }
    
    /** Replace dynamic fields by value **/
    private String renderMergeFields(String textToRender) {
        textToRender = textToRender.replace('{!Contact.Salutation}', account.Title__pc == null ? nullToText_Salutation(account.Salutation):nullToText_Title(account.Title__pc) );
        textToRender = textToRender.replace('{!Contact.FirstName}',  nullToText(account.FirstName));
        textToRender = textToRender.replace('{!Contact.LastName}',  nullToText(account.LastName));
        textToRender = textToRender.replace('{!Contact.OwnerFirstName}',  nullToText(owner.FirstName));
        textToRender = textToRender.replace('{!Contact.OwnerLastName}',  nullToText(owner.LastName));
        textToRender = textToRender.replace('{!User.FirstName}',  nullToText(UserInfo.getFirstName()));
        textToRender = textToRender.replace('{!User.LastName}',  nullToText(UserInfo.getLastName()));
        textToRender = textToRender.replace('{!User.DefaultStore__c}', nullToText(Sender.defaultStore__c));
        return textToRender;
    }
    
    /** Replace dynamic fields by value and formate for brower display **/
    private String renderMergeFieldsAndReplaceEncoding(String textToRender) {
    /*    
        textToRender = textToRender.replace('{!Contact.Salutation}', account.Salutation);
        textToRender = textToRender.replace('{!Contact.FirstName}', account.FirstName);
        textToRender = textToRender.replace('{!Contact.LastName}', account.LastName);
        textToRender = textToRender.replace('{!Contact.OwnerFirstName}', owner.FirstName);
        textToRender = textToRender.replace('{!Contact.OwnerLastName}', owner.LastName);
        textToRender = textToRender.replace('{!User.FirstName}', UserInfo.getFirstName());
        textToRender = textToRender.replace('{!User.LastName}', UserInfo.getLastName());
        textToRender = textToRender.replace('{!User.DefaultStore__c}', Sender.defaultStore__c);
     */
        textToRender = renderMergeFields(textToRender);    
        textToRender = textToRender.replace('\\n', '<br/>');
        return textToRender;
    }
    
    
    
    /**
    * Create new Task for current user and selected client when user click on SMS or Mobile
    **/
    @RemoteAction
    public static String createTask(String accountId, String numberPhone, String selectedTemplate) {
        system.debug ('*** createTask ');
        String tskSubject = Label.IC_SendEmail + ': ' + selectedTemplate; 
         
        String tskDescription =  String.format(Label.IC_TaskDescriptionEmail, new String[] {String.valueOf(Date.toDay()), UserInfo.getName(),  numberPhone, selectedTemplate });       
        
        Task newTask = IC_Factory.createTask(accountId, tskSubject, tskDescription, null, null, null, null, 'Email');
        newTask.TECH_is_AutoSave__c = true;
        return IC_Factory.insertTask(newTask);
    } 
    


Help Please !!

Hi,

 

I have read the Apex concepts but I am not getting enough confidence in Apex coding, probably I need to practice more.

I was looking for Apex code examples/samples and use cases in google, but couldnt get any.

Can you please let me know if you have links to the Apex code examples/samples and use cases for Apex to try practicing.

 

Also for Apex classes and triggers, please let me know the following:

 

1. On which parts of Apex, I need to start for code practice and how to proceed further.

2. While practicing, what should be the areas that I need to practice more

3. What areas of Apex are commonly used

4. What areas of Apex are complex which needs more practice

5. How to frame the use cases myself for Apex code practice.

 

 

Thanks,

Priya.

Our business had a need to prevent closed-won opportunities from being edited or deleted by anyone, so I used a page layout with the edit and delete buttons removed, a "locked" record type and a workflow rule to change the record type whenever an opportunity was marked closed-won.  This is working fine for us, however I just learned that if anyone searches for the opportunity, they do see an edit button in the list view.  I currently have made all the fields read only so that they cannot be changed, but what would have been the better way to handle this requirement?

 

Thanks, I appreciate any advice.

Good afternoon.

 

I'd like to customize the Actions available on a Related List. Specifically, I'd like to remove the Edit/Del options on the Opportunity Product Related List and add an "Inactivate" in their place. We have too many custom fields and objects to make customization of the entire page realistic, and I can't really override any of the main page views to accomodate this.

 

Anybody ever had any success with this?

 

Thanks

 

 

 

 

We have Translation Workbench enabled in our orgs but I cannot find a way to translate custom object labels.  Did I miss something obvious?  I can see where we translate custom field labels but nothing at the object level.  This impacts the Tab labels, the Create New... xxx label in the sidebar, the "New xxx" related list label and the label value returned from the DescribeSObject API, to name a few.

- Ed

10/22 - We figured it out.  The translations for the objects appear in a different part of the menu structure, not in the Translation Workbench, which would've been more intuitive.  For those who want to know, you have to navigate to Customize >>> Tab Names and Labels >>> Rename Tabs and Labels.  From there, you can toggle between the different languages and translate your object labels via Tab labels.  Odd but it works.


Message Edited by Edward Gee on 10-22-2008 04:31 PM