• krishna chaitanya 35
  • NEWBIE
  • 83 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 1
    Likes Given
  • 22
    Questions
  • 40
    Replies
Hello All,
I have a requiremnt to get the delegated approver email on the account based on the account createdby value.
Map <ID,ID> accnuser =new Map<ID,ID>();
List<Account> acc = new List<Account>();
acc=[select id,createdbyid from account where id='0011x000014rEQO'];
for(Account accs :acc){
    accnuser.put(accs.id,accs.createdbyid);
}

Map <ID,ID> userndelegated =new Map<ID,ID>();
List<User> uss =[select id,DelegatedApproverId,createdbyid,isactive from user where DelegatedApproverId!= NULL and ID IN :accnuser.values()];

for(user us :uss){
   userndelegated.put(us.id,us.DelegatedApproverId);
    system.debug('set of delegated id '+userndelegated);
}
 List <user> us1 = [select id,email from user where id IN:userndelegated.values()];
 Map <Id,String> us3 = new Map <Id,String>();
for(user us2 :us1){
    us3.put(us2.id,us2.email);
    system.debug('list of emails2'+us3);
}

system.debug('list of emails'+us1);

//Account acce = new Account();
//acce.Delegated_Approver_Email__c=us3.values();
//update acc;

I am able to retrive the delegated approver email and able stored in map us3 , the next step i want to update the a custom field in the same account with email address, i am missing something here .

can you help me to complete the operation and also please suggest to if there are unneccessary lines in code(optimization) and i want to put this in helper class and call from a trigger .

THank you in Advance
Hi All,
I am developing one visualforce page which render as word pdf ,but the footer is displayed in between header and content.Below is the code i developed:
 <apex:page standardController="Contact" sidebar="false" showHeader="false" renderAs="PDF">
 <head>
        <style type="text/css" media="print">
            span.cls_002 {
                font-size: 12.0px;
                color: rgb(0, 0, 0);
                font-weight: bold;
                font-style: normal;
                text-decoration: none
            }
            
            div.cls_002 {
                font-size: 9.0px;
                color: rgb(0, 0, 0);
                font-weight: bold;
                font-style: normal;
                text-decoration: none
            }
            
            @page {
                <!--size: 32.7cm 25.9cm;  
                margin-top: 20%;  
                margin-bottom:9%;
                margin-right: 7%;
                margin-left: 5%;
                size: A4;-->
                size: 26.7cm 19.9cm;
               margin: 1in .5in 2in .5in;
                @top-center {
                    content: element(header);
                }
                @bottom-center {
                    content: element(footer);
                }
            }
            
            div.content {
                padding: 0 0 30px 0;
            }
            
            div.header {
                font-weight: bold;
                padding: 10px;
                position: running(header);
            }
            
             div.footer {
            display: block;
            padding: 5px;
            position: running(footer);
        }
        .pagenumber:before {
            content: counter(page);
        }
        .pagecount:before {
            content: counter(pages);
        }
        </style>
        <style>
            body {
                font-family: 'Arial Unicode MS';
            }
            
            #index {
                font-family: 'Arial Unicode MS';
            }
            
            <!--@page {
                size: landscape;
            }
            
            --> <!--@page {
                size: 32.7cm 26.5cm;
                margin-top: 0.01cm;
                margin-left: 0.5cm;
                margin-right: 1.0cm;
                margin-bottom: 0.0cm;
            }
            
            -->
        </style>
    </head>

    <apex:form>

        <body id="index">

            <div class="header">
                <div>
                
                <table width="100%">
                        <tr>
                        <!--<td>
                            <apex:image value="{!$Resource.testLogo}" height="100%" width="100%"/>
                     </td>-->
                            <td width="50%" align="left" style="margin-left: -10px;">
                                <b><span style="font-size: 14.5px;margin-left: 0px; ">test-Werke GmbH</span></b>

                            </td>

                        </tr>
                    </table>

                    <table width="100%" border="0">
                        <tr>
                            <td width="15%">
                                <span class="cls_002">test-Werke testr testr 71-163 testr testr</span>
                            </td>
                            <td width="10%" align="right">
                                <span class="cls_002">Ihr Ansprechpartner:</span>
                            </td>
                            <br/>
                        </tr>
                        <tr>
                            <td width="15%">
                                <span class="cls_002">{!Contact.account.name}</span>
                            </td>
                            <td width="10%" align="right">
                                <span class="cls_002">{!$User.FirstName}</span>
                            </td>
                        </tr>
                        <tr>
                            <td width="15%">
                                <span class="cls_002">{!Contact.FirstName} {!Contact.LastName} </span>
                            </td>
                            <td width="10%" align="right">
                                <span class="cls_002"> {!$User.LastName} </span>
                            </td>

                        </tr>
                        <tr>
                            <td width="15%">
                                <span class="cls_002">{!contact.account.billingstreet}</span>
                            </td>
                            <td width="10%" align="right">
                                <span class="cls_002"> Customer Service</span>
                            </td>
                        </tr>
                        <tr>
                            <td width="15%">
                                <span class="cls_002">{!contact.account.billingpostalcode} {!contact.account.billingcity} </span>
                            </td>
                            <td width="10%" align="right">
                                <span class="cls_002">Phone: {!$User.Phone} </span>
                            </td>
                        </tr>
                        <tr>
                            <td width="15%">
                                <span class="cls_002">{!contact.account.billingcountry}</span>
                            </td>
                            <td width="10%" align="right">
                                <span class="cls_002">Fax: {!$User.Fax}</span>
                            </td>
                        </tr>
                        <tr>
                            <td width="15%">
                                <span class="cls_002">&nbsp;</span>
                            </td>
                            <td width="10%" align="right">
                                <span class="cls_002"> {!$User.Email}</span>
                            </td>
                        </tr>
                        <tr>
                            <td width="15%">
                                <span class="cls_002">&nbsp;</span>
                            </td>
                            <td width="10%" align="right">
                                <span>testr:</span>
                                <apex:outputText value="{0,date,dd'.'MM'.'yyyy}">
                                    <apex:param value="{!today()}" />
                                </apex:outputText>

                            </td>
                        </tr>
                    </table>
                </div>
            </div>
            
            <div class="footer">
                <div>Page <span class="pagenumber"/> of <span class="pagecount"/></div>
         <hr/>
         <div>
                <table width="100%">
                    <tr>
                        <td>
                            <span class="cls_002">test-Werke testr</span>
                        </td>
                        <td>
                            <span class="cls_002">testr</span>
                        </td>
                        <td>
                            <span class="cls_002">testr</span>
                        </td>
                        <td>
                            <span class="cls_002">info@testgroup.com</span>
                        </td>

                    </tr>
                    <tr>
                        <td>
                            <span class="cls_002">testr 71-163</span>
                        </td>
                        <td>
                            <span class="cls_002">testr testr</span>
                        </td>
                        <td>
                            <span class="cls_002">testr testr:testr</span>
                        </td>
                        <td>
                            <span class="cls_002">www.testr.com</span>
                        </td>

                    </tr>
                    <tr>
                        <td>
                            <span class="cls_002">D-testr testr</span>
                        </td>
                        <td>
                            <span class="cls_002">testr testr</span>
                        </td>
                        <td>
                            <span class="cls_002">testr:testr testr</span>
                        </td>
                        <td>
                            <span class="cls_002">&nbsp;</span>
                        </td>

                    </tr>
                    <tr>
                        <td>
                            <span class="cls_002">&nbsp;</span>
                        </td>
                        <td>
                            <span class="cls_002">testr.testr testr</span>
                        </td>
                        <td>
                            <span class="cls_002">&nbsp;</span>
                        </td>
                        <td>
                            <span class="cls_002">&nbsp;</span>
                        </td>

                    </tr>
                </table>
                </div>
                </div>
                <div class="content" style="border-style: double" >
                </div>
                        </body>
    </apex:form>
</apex:page>

sample out put:User-added image
Hello All,
I have a requirement to send a email to contacts.
1.In contact i created a check box send an email
2.i have a custom button to send email onclick,when the button is clicked it will fetch all the contacts marked "send an email=true".Till here i am able to achieve.
3.Constraint-->I need to  send a separate/different email to each and every contact (in To Address )instead of sending to list of contacts (in TO Address).
Can anyone please help me to solve this logic.
Regards,
Krishna Chaitanya.
Hello All,
I am fetching contacts and few email from custom lables to send an email from singlemailmessge but i am receiving several times .can any one help me to fix this issue.


public class IncidentTriggers {
    public static void SendEmailtoSiteCOntact(List < Incident__c > lnewind) {
    
    Map < ID, ID > mCaseIDtoSiteContID = new Map < ID, ID > ();
    Map < ID, Incident__c > mSiteIDtoIncident = new Map < ID, Incident__c > ();
    
 try{
 //Find all Incident__cs with Sites
    for (Incident__c c: lnewind) {
    if (c.Site__c != null) {
    system.debug('incident:' + c.ID);
    system.debug('Incident__c.Site__c:' + c.Site__c);
    mCaseIDtoSiteContID.put(c.ID, c.Site__c);
    system.debug('values in the map'+mCaseIDtoSiteContID);
    system.debug('incidnetid:' + mCaseIDtoSiteContID.get(c.id));
    //mSiteIDtoIncident.put(c.Site__c, c);
    }

 //-----------------------------------

 //Find All Site_Contacts referenced in the above incidents
 List < Site_Contact__c > lSContacts = [SELECT ID, Site__c, Role__c, Contact__c, contact__r.Email, Transfer_To_Customer_Complaint__c, Transfer_To_Supplier_Complaint__c, Transfer_To_Product_Specification__c FROM Site_Contact__c WHERE Site__c in : mCaseIDtoSiteContID.values()];

 //Incident__c c = mSiteIDtoIncident.get(sc.Site__c);


    List<Messaging.SingleEmailMessage> mails = new List<Messaging.SingleEmailMessage>();
    string address1=label.Incident_Manager1;
    string address2=label.Incident_Manager2;
    string address3=label.Incident_Manager3;
    string addresses=address1+':'+address2+':'+address3;
    for (Site_Contact__c sc: lSContacts) {
    if (sc.contact__r.Email != null || sc.contact__r.Email != 'null') {         
    addresses = addresses + ':' + sc.contact__r.Email;
    system.debug('intial Email Address Information ' + addresses);
    List < String > emailAddresses = new List < String > ();
    emailaddresses = addresses.split(':', 0);
    system.debug('final list of Email Address Information ' + emailaddresses);
    Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
    EmailTemplate et = [SELECT Id ,name FROM EmailTemplate WHERE Name = 'Test Template for incident'];
    email.ToAddresses = (emailaddresses);
    email.setTemplateId(et.Id);
    email.setSaveAsActivity(false);
    email.setTargetObjectId(sc.contact__c);
    email.setOrgWideEmailAddressId('0D2200000004EQx');
    email.setwhatid(c.id);
    mails.add(email);
    }
    }
    
    }
    Messaging.sendEmail(mails); 
}
    
catch(Exception ec)
       {    
          system.debug('error is' + ec);
        }

    
   }
}

Regards,
Krishna
Hi All,
I am developing one visualforce page which render as word doc,but the footer is displayed twice in the last page.
=============================sample code=========================
<apex:page standardController="Case"   sidebar="false" showHeader="false"  contentType="application/msword" cache="true" >
    
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
     <style type="text/css">
     
                
         p.MsoHeader, li.MsoHeader, div.MsoHeader{
                    margin:0in;
                    margin-top:.0001pt;
                    mso-pagination:widow-orphan;
                    tab-stops:center 3.0in right 6.0in;
                }
                p.MsoFooter, li.MsoFooter, div.MsoFooter{
                    margin:0in;
                    margin-bottom:.0001pt;
                    mso-pagination:widow-orphan;
                    tab-stops:center 3.0in right 6.0in;
                }
                @page Section1{
                    size:8.5in 11.0in; 
                    margin:0.5in 0.5in 0.5in 0.5in;
                    mso-header-margin:0.5in;
               
                    mso-footer:f1; 
                    mso-footer-margin:0.5in;
                    mso-paper-source:0;
                }
                div.Section1{
                    page:Section1;
                }
                table#hrdftrtbl{
                    margin:0in 0in 0in 9in;
                }
            </style>
</head> 
     <apex:form >
    
    <body>
     <br clear="all" style="page-break-before:always" />
        <div class="Section1">
           <table width="100%" border="1" >
                <tr>
                  <td width="40%" align="Center" style="margin-left: -20px;">
                           
                         
                       <apex:image  width="150" height="75"/>
                       
                   </td>
                    <td width="40%" align="center" >
                     <b><span style="font-size: 20px;">Test Report </span></b><br/>
                     <b><span style="font-size: 16px;padding-left: 5px;">Test Report</span></b> 
                  </td> 
                  
                     <td width="20%" align="center">
                    <span >Created Date:</span> <br/>
                    <apex:outputText value="{0,date,dd'.'MM'.'yyyy}">
                            <apex:param value="{!today()}"/>
                            </apex:outputText><br/>
                            <span style="font-size: 16px;padding-left: 5px;">Version 1</span>
                                               
                         </td>
                
                    
                    
                    
                    
                    </tr> 
                 
            </table><br/>
            
               
            
            </div>
            <div style='mso-element:footer' id="f1" >
                               
                                    <table width="100%" border="0" cellspacing="0" cellpadding="0" >
                                     <p class="MsoFooter">
                                        <tr>
                                            <td width="50%" word-spacing="5px">
                                                Constructed: SHEQ{!$User.FirstName} {!$User.LastName}<br/>
                                                VA 7.5.1 Steering documented information of conformity
                                            </td>
                                            <td align="center" width="20%">
                                           <apex:outputText value="{0,date,dd'.'MM'.'yyyy}">
                                            <apex:param value="{!Case.CreatedDate}"/>
                                            </apex:outputText>
                                            </td>
                                            <td align="center" width="30%">
                                                Page <span style='mso-field-code: PAGE '></span> of <span style='mso-field-code: NUMPAGES '></span>
                                                <br/>
                                                Print Date:<apex:outputText value="{0,date,dd'.'MM'.'yyyy}">
                                                <apex:param value="{!today()}"/>
                                                </apex:outputText>
                                            </td>
                                        </tr>
                                        </p>
                                    </table>
                                
                            </div>
                 
                          
        </body>
        
        </apex:form>
        
      
        </apex:page>
=================================================================
=====================sample output============================
User-added image
============================================================
Hi All,
I have field on opportunity which shows contract expiration date ,but a reminder should be sent to opportunity owner before 6 months .I need a  formula to calculate today()-6 months, i tried Today()-180 but it misses some days.

Thanks for your help in advance!........
Regards,
Krishna.
Hi All,
I am trying to display case object content to word document,everything is successfull except two things.
1.Footer is displaying under the header information.
2.Image is not displayed when the word document is downloaded.

==============Sample Code and out put ===================================
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
     <style type="text/css">
     
                
             p.MsoFooter, li.MsoFooter, div.MsoFooter{
                    margin:0in;
                    margin-bottom:.0001pt;
                    mso-pagination:widow-orphan;
                    tab-stops:center 3.0in right 6.0in;
                }
                @page Section1{
                    size:8.5in 11.0in; 
                    margin:0.5in 0.5in 0.5in 0.5in;
                    mso-footer:f1; 
                    mso-footer-margin:0.5in;
                    mso-paper-source:0;
                }
                div.Section1{
                    page:Section1;
                }
                /*Below is the style to prevent the repetition of header and Footer.. Cheers!!!*/
                table#hrdftrtbl{
                margin:0in 0in 0in 15in;
            } 
                
            </style>
</head> 
     <apex:form >
   
    <body>
    
        <div class="Section1">
           <table width="100%" border="1" id="hrdftrtbl">
             <td>
             <div>
              <!--Header-->
             <!--<div style='mso-element:header' id="h1" >
             <p class="MsoHeader">-->
                <tr >
                  <td width="40%" align="Center" style="margin-left: -20px;">
                           
                            <apex:image value="https://c.cs84.content.force.com/servlet/servlet.ImageServer?id=0155E0000001AK5QAM&oid=00D5E0000004byY&lastMod=1455786672000&contentType=image/png" width="150" height="75"/>
                   </td>
                    <td width="40%" align="center" >
                     <b><span style="font-size: 14.5px;">test </span></b><br/>
                     <b><span style="font-size: 16px;padding-left: 5px;">test</span></b> 
                  </td> 
                  
                     <td width="20%" align="center">
                    <span >Created Date:</span> <br/>
                    <apex:outputText value="{0,date,dd'-'MMM'-'yyyy}">
                            <apex:param value="{!Case.CreatedDate}"/>
                            </apex:outputText>
                    
                       </td>     
                    </tr> 
                <!--</p>-->
                 </div>
                 </td>
            </table>

                     <div style='mso-element:footer' id="f1" class="MsoFooter,Section1" >
                                <p class="MsoFooter">
                                    <table width="100%" border="0" cellspacing="0" cellpadding="0" >
                                        <tr>
                                            <td width="50%">
                                                Constructed: test{!case.Createdby.name}<br/>
                                                test
                                            </td>
                                            <td align="center" width="20%">
                                            <apex:outputText value="{0,date,dd'-'MMM'-'yyyy}">
                                            <apex:param value="{!Case.CreatedDate}"/>
                                            </apex:outputText>
                                            </td>
                                            <td align="center" width="30%">
                                                Page <span style='mso-field-code: PAGE '></span> of <span style='mso-field-code: NUMPAGES '></span>
                                                <br/>
                                                Print Date:<apex:outputText value="{0,date,dd'-'MMM'-'yyyy}">
                                                <apex:param value="{!today()}"/>
                                                </apex:outputText>
                                            </td>
                                        </tr>
                                    </table>
                                </p>
                            </div>
        
   </div>        
=================Sample Output========================User-added image
HI All,
I have a junction object called locationcontact which is related to location (masterdetail) object and contact(masterdetail).Below the location a related list is placed to enter a location contact .I need to restrict if the user tries to assign a same contact to location (means avoid duplication of same contact to location).I am writing a trigger to solve this ,but unable to fetch rows.

trigger duplocationcontact on location_Contact__c (before insert) {
    
    for (location_Contact__c ci : trigger.new) {
            
        List<location_Contact__c> resultList = [SELECT id FROM location_Contact__c WHERE  location__c = :ci.location__c    AND Contact__c = :ci.Contact__c.name];
                 
        if (!resultList.isEmpty()) {
              
        ci.addError('Duplicate record, a location contact already exists');
        }
        }
}
Hi ,
I tried to display list of accounts with searched name in the pageblock in visualforce using javascipt remoting.In the soql i am getting all the records but unable to display in the vf.Can anyone solve this puzzle.

apex:page
<apex:page controller="AccountRemoter">
<script type="text/javascript">
function getRemoteAccount() {
    var accountName = document.getElementById('acctSearch').value;

    Visualforce.remoting.Manager.invokeAction(
        '{!$RemoteAction.AccountRemoter.getAccount}',
        accountName,
        function(result, event){
            if (event.status) {
                // Get DOM IDs for HTML and Visualforce elements like this
                for(i=0;i<=result.length;i++){
                document.getElementById('remoteAcctId').innerHTML = result[i].Id
                document.getElementById(
                    "{!$Component.block.blockSection.secondItem.acctNumEmployees}"
                    ).innerHTML = result[i].NumberOfEmployees;
                    document.getElementById(
                    "{!$Component.block.blockSection.thirdItem.nameofacct}"
                    ).innerHTML = result[i].Name;
                    }
            } else if (event.type === 'exception') {
                document.getElementById("responseErrors").innerHTML =
                    event.message + "<br/>\n<pre>" + event.where + "</pre>";
            } else {
                document.getElementById("responseErrors").innerHTML = event.message;
            }
         },
         {escape: true}
     );
   }
  </script>

    <input id="acctSearch" type="text"/>
    <button onclick="getRemoteAccount()">Fetch Accounts</button>
    <div id="responseErrors"></div>

    <apex:pageBlock id="block">
    
    <apex:pageBlockSection id="blockSection" columns="3">
   
        <apex:pageBlockSectionItem id="firstItem">
            <span id="remoteAcctId"/>
        </apex:pageBlockSectionItem>
       
        <apex:pageBlockSectionItem id="thirdItem">
            <apex:outputText id="nameofacct"/>
        </apex:pageBlockSectionItem>
        
        <apex:pageBlockSectionItem id="secondItem">
            <apex:outputText id="acctNumEmployees"/>
        </apex:pageBlockSectionItem>
         
    </apex:pageBlockSection>
   </apex:pageBlock>
   </apex:page>

====class====
global with sharing class AccountRemoter {

public String accountName { get; set; }
public Account account { get; set; }
public AccountRemoter() {

}

@RemoteAction
global static List<Account> getAccount(String accountName) {

string strLikeString = '%'+accountName+'%';
        string strSOQL = 'select id,Name,NumberofEmployees from Account where name LIKE: strLikeString order by Name asc';
        List<Account> account = database.query(strSOQL);
   
return account;
}
}

HI,

Can any one help me to write logic for this:
Two conditions in  user obj the  out of office must be true  true and case last modified date 1 week then route the cases to  queue ..

Thanks,
krishna.
Hi All,

I have an requirement to override standard salesforce page with visualforce page in "New" button for opportunity ,it is working in salesforce classic as expected but the same is not working in lightning experience.can any one help me on this how to re-direct in lightning salesforce.
My code:
Page:
<apex:page standardController="Opportunity" extensions="MyController" action="{!redirect}"> </apex:page>

Controller:
public with sharing class MyController{

    public MyController(ApexPages.StandardController controller) {

    }

    public PageReference redirect() {
           PageReference pr = new PageReference('/006/e');
           
            pr.getParameters().put('retURL',ApexPages.currentPage().getparameters().get('retURL'));    
            pr.getParameters().put('ent',ApexPages.currentPage().getparameters().get('ent'));  
            pr.getParameters().put('nooverride','1');  
            pr.getParameters().put('opp3', 'Name_Opco_Product');
          
           return pr;
     
    }
}

Thanks in advance,
Krishna.
i am new for lightning and i have a lightning component and i want add a loading spinner when response is coming from server.
please help thanks in advance
Hey Guys,

Please helpe me. I am stuck, non of the users can see report. They can see the report folder but when they try to access report they get insufficient privilage error. Infact they can't even access unifed folder reports. Which is visible to all users. I am not sure why this is happening. I gave all these permissions but still they cant see: 

1) Manage Reports in Public Folders
2) Manage Dashboards in Public Folders
3) View Reports in Public Folders
4) View Dashboards in Public Folders
5)Create Report Folders
6) Create Dashboard Folders
7) Edit My Reports
8) Edit My Dashboards

Please let me know if I am missing something. Thanks.
 
Hi All ,
While  redering  Quote as word file ,I am facing a problem like ,Header is repeting twice in first page and footer  is repeating twice in last page .
Can nay one suggest me how to solve this issue .
Below is my code snipnet .



<apex:page sidebar="false" showChat="false" showHeader="false" contentType="application/msword#Test.doc" cache="true"> <html> <head> <meta http-equiv="Content-Type" content="text/html;charset=UTF-8" /> <style> @page Main { mso-header:h1; mso-footer:f1; } div.Main{ page:Main; } p.MyFoot, li.MyFoot, div.MyFoot{ mso-pagination:widow-orphan; tab-stops:center 216.0pt right 432.0pt; } p.MyHead { } </style> </head> <body> <div class="Main"> <div style="mso-element:header" id="h1"> <img src="https://c.cs17.content.force.com/servlet/servlet.ImageServer?id=015g000000044RX&oid=00Dg0000003MfeB&lastMod=1421154746000" style="height:10px;width:10px"/> </div> <div>Ashutosh Kumar Srivastava</div> <br style="page-break-after: always;"/> <div style="mso-element:footer" id="f1"> <img src="https://c.cs17.content.force.com/servlet/servlet.ImageServer?id=015g000000044RS&oid=00Dg0000003MfeB&lastMod=1421154652000" style="height:10px;width:10px"/> </div> </div> </body> </html> </apex:page>


Any help is heartily appreciated .
 
Hi experts,
I found a Salesforce object named OpportunityContactRole by using the IDE (Eclipse) and I want to add a new trigger for this object but I got the following Error message when try to save the new created trigger:
    Save error: SObject type does not allow triggers: OpportunityContactRole
I really need to add the special processing to this object before updating, do any experts have any idea how to fix this issue?
Best regards!
Boi Hue


Message Edited by boihue on 12-09-2008 11:02 AM

Message Edited by boihue on 12-09-2008 11:02 AM