-
ChatterFeed
-
0Best Answers
-
1Likes Received
-
1Likes Given
-
22Questions
-
40Replies
Help with update operation -Unable to pass the ID
Can any one help me with the update operation
public class AccountUpdateWithDelegated {
public static void fillDelegatedApproverEmail(Set<id> accn) {
List<ProcessInstance> pi = new List<ProcessInstance>();
Map <ID,ID> prinst =new Map<ID,ID>();
Map <ID,ID> Prsinswi =new Map<ID,ID>();
Map <ID,ID> userndelegated =new Map<ID,ID>();
List < Account > ac = new List < Account > ();
pi=[select id,Status,TargetObjectId ,LastActorId from ProcessInstance where TargetObjectId IN :accn];
for (ProcessInstance ps : pi){
prinst.put(ps.TargetObjectId,ps.id);
system.debug('list of id '+prinst);
}
List<ProcessInstanceWorkitem> piw = new List<ProcessInstanceWorkitem>();
piw =[select id,ActorId,ProcessInstanceId from ProcessInstanceWorkitem where ProcessInstanceId IN :prinst.values()];
for (ProcessInstanceWorkitem psiw :piw){
Prsinswi.put(psiw.id,psiw.ActorId);
system.debug('list of process instance items in piws'+prinst.values());
}
List<user> us = [select id,DelegatedApproverId,Email,createdbyid,isactive from user where DelegatedApproverId!= NULL and ID IN :Prsinswi.values()];
system.debug('Delegated approver '+us);
for(user usrs :us){
userndelegated.put(usrs.id,usrs.DelegatedApproverId);
system.debug('set of delegated id '+userndelegated);
}
List <user> us1 = [select id,email from user where id IN:userndelegated.values()];
for (user usrss : us1) {
Account acce = new Account();
acce.Delegated_Approver_Email__c = usrss.email;
//acce.id = prinst.get.ps.TargetObjectId;
system.debug('Delegated_Approver_Email__c' + acce.Delegated_Approver_Email__c);
ac.add(acce);
}
If (!ac.isEmpty()){
update ac;
}
}
}
Can any one help me with the update operation
public class AccountUpdateWithDelegated {
public static void fillDelegatedApproverEmail(Set<id> accn) {
List<ProcessInstance> pi = new List<ProcessInstance>();
Map <ID,ID> prinst =new Map<ID,ID>();
Map <ID,ID> Prsinswi =new Map<ID,ID>();
Map <ID,ID> userndelegated =new Map<ID,ID>();
List < Account > ac = new List < Account > ();
pi=[select id,Status,TargetObjectId ,LastActorId from ProcessInstance where TargetObjectId IN :accn];
for (ProcessInstance ps : pi){
prinst.put(ps.TargetObjectId,ps.id);
system.debug('list of id '+prinst);
}
List<ProcessInstanceWorkitem> piw = new List<ProcessInstanceWorkitem>();
piw =[select id,ActorId,ProcessInstanceId from ProcessInstanceWorkitem where ProcessInstanceId IN :prinst.values()];
for (ProcessInstanceWorkitem psiw :piw){
Prsinswi.put(psiw.id,psiw.ActorId);
system.debug('list of process instance items in piws'+prinst.values());
}
List<user> us = [select id,DelegatedApproverId,Email,createdbyid,isactive from user where DelegatedApproverId!= NULL and ID IN :Prsinswi.values()];
system.debug('Delegated approver '+us);
for(user usrs :us){
userndelegated.put(usrs.id,usrs.DelegatedApproverId);
system.debug('set of delegated id '+userndelegated);
}
List <user> us1 = [select id,email from user where id IN:userndelegated.values()];
for (user usrss : us1) {
Account acce = new Account();
acce.Delegated_Approver_Email__c = usrss.email;
//acce.id = prinst.get.ps.TargetObjectId;
system.debug('Delegated_Approver_Email__c' + acce.Delegated_Approver_Email__c);
ac.add(acce);
}
If (!ac.isEmpty()){
update ac;
}
}
}
Can any one help me with the update operation
-
- krishna chaitanya 35
- July 21, 2020
- Like
- 0
- Continue reading or reply
Assign a value retrived from Map to a custom field in account
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
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
-
- krishna chaitanya 35
- July 19, 2020
- Like
- 0
- Continue reading or reply
Help me with the code coverage
Hello All,
I have class which is used to fetch attachment and sending an email.I wrote the test class but it is shwoing only 28% code coverage.Can any one please help me to cover this code.
=================class=======================
public class sendEmailtoContact {
public String subject {
get;
set;
}
public String body {
get;
set;
}
private final Account account;
public List < String > ToemailAddresses = new List < String > ();
public List < contact > lsc = new List < contact > ();
public sendEmailtoContact() {}
public PageReference send() {
User Usr = new User();
Usr = [SELECT country FROM User WHERE Id = : UserInfo.getUserId()];
lsc = [select id, name, Email, CustomDeclarationLetterDE__c, CustomDeclarationLetterUK__c, CustomDeclarationLetterItaly__c, CustomDeclarationLetterFr__c from contact where CustomDeclarationLetterDE__c = true or CustomDeclarationLetterUK__c = true or CustomDeclarationLetterItaly__c = true or CustomDeclarationLetterFr__c = true];
System.debug('List of contacts retrieved' + lsc);
List < Messaging.SingleEmailMessage > mails = new List < Messaging.SingleEmailMessage > ();
for (contact cs: lsc) {
ToemailAddresses.add(cs.email);
system.debug('list of ToemailAddresses information' + ToemailAddresses);
// Define the email
Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
PageReference pdf = Page.CustomDeclarationLetter;
pdf.getParameters().put('id', cs.id);
pdf.setRedirect(true);
// need to pass unit test -- current bug
// Take the PDF content
Blob b = pdf.getContent();
// Create the email attachment
String subject1='Long-Term ';
String Htmlbody= 'test123'
Messaging.EmailFileAttachment efa = new Messaging.EmailFileAttachment();
efa.setFileName('CustomDeclarationLetter.pdf');
efa.setBody(b);
email.setSubject(subject1);
email.setOrgWideEmailAddressId('0D2200000004EQx');
email.setHtmlBody(Htmlbody);
email.setTargetObjectId(cs.id);
email.setFileAttachments(new Messaging.EmailFileAttachment[] {efa});
mails.add(email);
// Sends the email
//Based on the current logged in user the respective checkbox will be updated to false
if (Usr.country == 'Germany') {
cs.CustomDeclarationLetterDE__c = false;
} else if (Usr.country == 'UK') {
cs.CustomDeclarationLetterUK__c = false;
} else if (Usr.country == 'Italy') {
cs.CustomDeclarationLetterItaly__c = false;
} else {
cs.CustomDeclarationLetterFr__c = false;
}
}
if (!mails.isEmpty()) {
Messaging.sendEmail(mails);
update lsc;
}
return null;
}
}
============class=============================
===========================test class========================================
@isTest
public class TestsendEmailtoContact{
public static testMethod void testSendemailmessageContact()
{
Profile p = [SELECT Id FROM profile WHERE name='System Administrator'];
User u = new User(alias = 'MTstCN', email='newuser@testorg.com',
emailencodingkey='UTF-8', lastname='Testing', languagelocalekey='en_US',
localesidkey='en_US', profileid = p.Id,
timezonesidkey='Europe/Berlin', username='m_tstComplaintNum@tstorg20110329.tst');
insert u;
system.runAs(u){
//Create an Account of Record Type Customer
Schema.DescribeSObjectResult da = Schema.SObjectType.Account;
Map<String,Schema.RecordTypeInfo> rtAMapByName = da.getRecordTypeInfosByName();
Schema.RecordTypeInfo rtInfoMInt= rtAMapByName.get('Customer');
ID accCustomerRTypeID = rtInfoMInt.getRecordTypeId();
Account a = new Account(Name='M_Tst_ComplaintNumber') ;
a.OwnerId=u.ID;
a.RecordTypeID=label.Account_Mauser_Record_TypeID;
insert a;
system.debug('Account ID:' + a.ID);
Contact ct = new Contact();
ct.AccountId=a.ID;
ct.LastName='Test contact';
ct.Email='Test@test.com';
ct.RecordTypeId=Label.Mauser_Contact_Rt;
ct.Inactive_Contact__c=false;
insert ct;
email.plainTextBody = 'This should become a note';
email.fromAddress ='test@test.com';
String contactEmail = 'jsmith@salesforce.com';
email.ccAddresses = new String[] {'Jon Smith <' + contactEmail + '>'};
email.subject = 'Dummy Account Name 123';
PageReference pref = Page.CustomDeclarationLetter;
pref.getParameters().put('id',ct.id);
Test.setCurrentPage(pref);
sendEmailtoContact con = new sendEmailtoContact();
//------------------- START TEST-------------------
Test.startTest();
// submit the record
pref = con.send(ct.id);
Test.stopTest();
}
}
}
===============================================test class===================
I have class which is used to fetch attachment and sending an email.I wrote the test class but it is shwoing only 28% code coverage.Can any one please help me to cover this code.
=================class=======================
public class sendEmailtoContact {
public String subject {
get;
set;
}
public String body {
get;
set;
}
private final Account account;
public List < String > ToemailAddresses = new List < String > ();
public List < contact > lsc = new List < contact > ();
public sendEmailtoContact() {}
public PageReference send() {
User Usr = new User();
Usr = [SELECT country FROM User WHERE Id = : UserInfo.getUserId()];
lsc = [select id, name, Email, CustomDeclarationLetterDE__c, CustomDeclarationLetterUK__c, CustomDeclarationLetterItaly__c, CustomDeclarationLetterFr__c from contact where CustomDeclarationLetterDE__c = true or CustomDeclarationLetterUK__c = true or CustomDeclarationLetterItaly__c = true or CustomDeclarationLetterFr__c = true];
System.debug('List of contacts retrieved' + lsc);
List < Messaging.SingleEmailMessage > mails = new List < Messaging.SingleEmailMessage > ();
for (contact cs: lsc) {
ToemailAddresses.add(cs.email);
system.debug('list of ToemailAddresses information' + ToemailAddresses);
// Define the email
Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
PageReference pdf = Page.CustomDeclarationLetter;
pdf.getParameters().put('id', cs.id);
pdf.setRedirect(true);
// need to pass unit test -- current bug
// Take the PDF content
Blob b = pdf.getContent();
// Create the email attachment
String subject1='Long-Term ';
String Htmlbody= 'test123'
Messaging.EmailFileAttachment efa = new Messaging.EmailFileAttachment();
efa.setFileName('CustomDeclarationLetter.pdf');
efa.setBody(b);
email.setSubject(subject1);
email.setOrgWideEmailAddressId('0D2200000004EQx');
email.setHtmlBody(Htmlbody);
email.setTargetObjectId(cs.id);
email.setFileAttachments(new Messaging.EmailFileAttachment[] {efa});
mails.add(email);
// Sends the email
//Based on the current logged in user the respective checkbox will be updated to false
if (Usr.country == 'Germany') {
cs.CustomDeclarationLetterDE__c = false;
} else if (Usr.country == 'UK') {
cs.CustomDeclarationLetterUK__c = false;
} else if (Usr.country == 'Italy') {
cs.CustomDeclarationLetterItaly__c = false;
} else {
cs.CustomDeclarationLetterFr__c = false;
}
}
if (!mails.isEmpty()) {
Messaging.sendEmail(mails);
update lsc;
}
return null;
}
}
============class=============================
===========================test class========================================
@isTest
public class TestsendEmailtoContact{
public static testMethod void testSendemailmessageContact()
{
Profile p = [SELECT Id FROM profile WHERE name='System Administrator'];
User u = new User(alias = 'MTstCN', email='newuser@testorg.com',
emailencodingkey='UTF-8', lastname='Testing', languagelocalekey='en_US',
localesidkey='en_US', profileid = p.Id,
timezonesidkey='Europe/Berlin', username='m_tstComplaintNum@tstorg20110329.tst');
insert u;
system.runAs(u){
//Create an Account of Record Type Customer
Schema.DescribeSObjectResult da = Schema.SObjectType.Account;
Map<String,Schema.RecordTypeInfo> rtAMapByName = da.getRecordTypeInfosByName();
Schema.RecordTypeInfo rtInfoMInt= rtAMapByName.get('Customer');
ID accCustomerRTypeID = rtInfoMInt.getRecordTypeId();
Account a = new Account(Name='M_Tst_ComplaintNumber') ;
a.OwnerId=u.ID;
a.RecordTypeID=label.Account_Mauser_Record_TypeID;
insert a;
system.debug('Account ID:' + a.ID);
Contact ct = new Contact();
ct.AccountId=a.ID;
ct.LastName='Test contact';
ct.Email='Test@test.com';
ct.RecordTypeId=Label.Mauser_Contact_Rt;
ct.Inactive_Contact__c=false;
insert ct;
email.plainTextBody = 'This should become a note';
email.fromAddress ='test@test.com';
String contactEmail = 'jsmith@salesforce.com';
email.ccAddresses = new String[] {'Jon Smith <' + contactEmail + '>'};
email.subject = 'Dummy Account Name 123';
PageReference pref = Page.CustomDeclarationLetter;
pref.getParameters().put('id',ct.id);
Test.setCurrentPage(pref);
sendEmailtoContact con = new sendEmailtoContact();
//------------------- START TEST-------------------
Test.startTest();
// submit the record
pref = con.send(ct.id);
Test.stopTest();
}
}
}
===============================================test class===================
-
- krishna chaitanya 35
- March 09, 2018
- Like
- 0
- Continue reading or reply
footer is displayed above the content in vf pgae when it is rendered as a pdf
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"> </span>
</td>
<td width="10%" align="right">
<span class="cls_002"> {!$User.Email}</span>
</td>
</tr>
<tr>
<td width="15%">
<span class="cls_002"> </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"> </span>
</td>
</tr>
<tr>
<td>
<span class="cls_002"> </span>
</td>
<td>
<span class="cls_002">testr.testr testr</span>
</td>
<td>
<span class="cls_002"> </span>
</td>
<td>
<span class="cls_002"> </span>
</td>
</tr>
</table>
</div>
</div>
<div class="content" style="border-style: double" >
</div>
</body>
</apex:form>
</apex:page>
sample out put:
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"> </span>
</td>
<td width="10%" align="right">
<span class="cls_002"> {!$User.Email}</span>
</td>
</tr>
<tr>
<td width="15%">
<span class="cls_002"> </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"> </span>
</td>
</tr>
<tr>
<td>
<span class="cls_002"> </span>
</td>
<td>
<span class="cls_002">testr.testr testr</span>
</td>
<td>
<span class="cls_002"> </span>
</td>
<td>
<span class="cls_002"> </span>
</td>
</tr>
</table>
</div>
</div>
<div class="content" style="border-style: double" >
</div>
</body>
</apex:form>
</apex:page>
sample out put:
-
- krishna chaitanya 35
- February 28, 2018
- Like
- 0
- Continue reading or reply
Send a separate email to each contact
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.
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.
-
- krishna chaitanya 35
- February 27, 2018
- Like
- 0
- Continue reading or reply
Multiple emails are recived from singleemailmessage(Recurring Emails)
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
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
-
- krishna chaitanya 35
- October 24, 2017
- Like
- 0
- Continue reading or reply
After Update Trigger(unable to fetch records when condition is written)
Hello All,
I am trying a write a trigger on contact object .My scenario is i have a check box in contact obj inactive contact and when it is checked true my trigger should delete the existing contact in child object.i tried to fetch id of the contact,in run time i am facing an error "System.FinalException: Record is read-only".Below is my code
rigger delsitecotact on Contact(after update) {
set < id > cts = new set < id > ();
for (Contact ci: trigger.new)
if(ci.Inactive_Contact__c = true)
cts.add(ci.id);
system.debug('list of contacts' + cts);
List < Site_Contact__c > resultList = [SELECT id, Contact__r.name, Contact__r.id, name FROM Site_Contact__c where Contact__r.id IN: cts];
if (!resultList.isEmpty()) {
delete resultList;
System.debug('deleted list of contacts ' + resultList[0].id + ' name is ' + resultList[0].Name);
}
Regards,
Krishna.
}
I am trying a write a trigger on contact object .My scenario is i have a check box in contact obj inactive contact and when it is checked true my trigger should delete the existing contact in child object.i tried to fetch id of the contact,in run time i am facing an error "System.FinalException: Record is read-only".Below is my code
rigger delsitecotact on Contact(after update) {
set < id > cts = new set < id > ();
for (Contact ci: trigger.new)
if(ci.Inactive_Contact__c = true)
cts.add(ci.id);
system.debug('list of contacts' + cts);
List < Site_Contact__c > resultList = [SELECT id, Contact__r.name, Contact__r.id, name FROM Site_Contact__c where Contact__r.id IN: cts];
if (!resultList.isEmpty()) {
delete resultList;
System.debug('deleted list of contacts ' + resultList[0].id + ' name is ' + resultList[0].Name);
}
Regards,
Krishna.
}
-
- krishna chaitanya 35
- September 26, 2017
- Like
- 0
- Continue reading or reply
VF page Doc conversion - Footeris being displayed twice on last page.
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============================

============================================================
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============================
============================================================
-
- krishna chaitanya 35
- September 13, 2017
- Like
- 0
- Continue reading or reply
calculate the given date minus 6 months
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.
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.
-
- krishna chaitanya 35
- August 21, 2017
- Like
- 0
- Continue reading or reply
images are not displaying in Visualforce page when rendered as word document and repetition of footer
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========================
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========================
-
- krishna chaitanya 35
- August 17, 2017
- Like
- 0
- Continue reading or reply
junction object trigger
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');
}
}
}
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');
}
}
}
-
- krishna chaitanya 35
- August 09, 2017
- Like
- 0
- Continue reading or reply
Javascript remoting to display a list of records in a pageblock or pageblock table
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;
}
}
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;
}
}
-
- krishna chaitanya 35
- May 28, 2017
- Like
- 0
- Continue reading or reply
route cases to queue(Batch Class)
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.
-
- krishna chaitanya 35
- March 27, 2017
- Like
- 0
- Continue reading or reply
Added a validation rule on opportunity if no primary contact assigned and assigning a primary conatct on contactrole to custom field in opportunity
Hi ,
I have written a trigger on opportunity for counting contcat roles and verifying primary contact assigned or not along with this i am copying the primary contcat in oppcontact role to Custom field in opportunity.Trigger is working fine but only the operation done in opportunity but not in contcatrole.please help to slove this.please find the below code.
trigger Check_Contact_Roles_List on Opportunity(before insert, before update,after insert,after update) {
//Variable
Boolean isPrimary;
Integer iCount;
//APEX Code
Map < String, Opportunity > oppty_con = new Map < String, Opportunity > (); //check if the contact role is needed and add it to the oppty_con map
for (Integer i = 0; i < Trigger.new.size(); i++) {
oppty_con.put(Trigger.new[i].id,
Trigger.new[i]);
}
isPrimary = False;
for (List < OpportunityContactRole > oppcntctrle: [select OpportunityId from OpportunityContactRole where(OpportunityContactRole.IsPrimary = True and OpportunityContactRole.OpportunityId in : oppty_con.keySet())]) {
if (oppcntctrle.Size() > 0) {
isPrimary = True;
}
}
iCount = 0;
for (List < OpportunityContactRole > oppcntctrle2: [select OpportunityId from OpportunityContactRole where(OpportunityContactRole.OpportunityId in : oppty_con.keySet())]) //Query for Contact Roles
{
if (oppcntctrle2.Size() > 0) {
iCount = oppcntctrle2.Size();
}
}
for (Opportunity Oppty: system.trigger.new) //Check if roles exist in the map or contact role isn't required
{
Oppty.Contact_Roles_Counter__c = iCount;
Oppty.Primary_Contact_Assigned__c = isPrimary;
}
if(Trigger.isInsert || Trigger.isUpdate){
Map<Id, String> mapOppIdWithConLN = new Map<Id,String>();
for(OpportunityContactRole oCR : [select Id,IsPrimary,Contact.Name, Contact.LastName, OpportunityId From OpportunityContactRole where opportunityId IN : Trigger.new AND isprimary = true]) {
//Populate map with values
mapOppIdWithConLN.put(oCR.OpportunityId, oCR.Contact.LastName);
}
for(Opportunity opp : Trigger.new) {
//Check if map contains Opportunity
if(mapOppIdWithConLN.containsKey(opp.Id))
opp.Primary_Contact_Name__c = mapOppIdWithConLN.get(opp.Id);
}
}
}
Thanks,
Krishna
I have written a trigger on opportunity for counting contcat roles and verifying primary contact assigned or not along with this i am copying the primary contcat in oppcontact role to Custom field in opportunity.Trigger is working fine but only the operation done in opportunity but not in contcatrole.please help to slove this.please find the below code.
trigger Check_Contact_Roles_List on Opportunity(before insert, before update,after insert,after update) {
//Variable
Boolean isPrimary;
Integer iCount;
//APEX Code
Map < String, Opportunity > oppty_con = new Map < String, Opportunity > (); //check if the contact role is needed and add it to the oppty_con map
for (Integer i = 0; i < Trigger.new.size(); i++) {
oppty_con.put(Trigger.new[i].id,
Trigger.new[i]);
}
isPrimary = False;
for (List < OpportunityContactRole > oppcntctrle: [select OpportunityId from OpportunityContactRole where(OpportunityContactRole.IsPrimary = True and OpportunityContactRole.OpportunityId in : oppty_con.keySet())]) {
if (oppcntctrle.Size() > 0) {
isPrimary = True;
}
}
iCount = 0;
for (List < OpportunityContactRole > oppcntctrle2: [select OpportunityId from OpportunityContactRole where(OpportunityContactRole.OpportunityId in : oppty_con.keySet())]) //Query for Contact Roles
{
if (oppcntctrle2.Size() > 0) {
iCount = oppcntctrle2.Size();
}
}
for (Opportunity Oppty: system.trigger.new) //Check if roles exist in the map or contact role isn't required
{
Oppty.Contact_Roles_Counter__c = iCount;
Oppty.Primary_Contact_Assigned__c = isPrimary;
}
if(Trigger.isInsert || Trigger.isUpdate){
Map<Id, String> mapOppIdWithConLN = new Map<Id,String>();
for(OpportunityContactRole oCR : [select Id,IsPrimary,Contact.Name, Contact.LastName, OpportunityId From OpportunityContactRole where opportunityId IN : Trigger.new AND isprimary = true]) {
//Populate map with values
mapOppIdWithConLN.put(oCR.OpportunityId, oCR.Contact.LastName);
}
for(Opportunity opp : Trigger.new) {
//Check if map contains Opportunity
if(mapOppIdWithConLN.containsKey(opp.Id))
opp.Primary_Contact_Name__c = mapOppIdWithConLN.get(opp.Id);
}
}
}
Thanks,
Krishna
-
- krishna chaitanya 35
- October 24, 2016
- Like
- 0
- Continue reading or reply
Need help in lightning how to override standard new page in opportunity with visualforce page
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 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.
-
- krishna chaitanya 35
- September 14, 2016
- Like
- 0
- Continue reading or reply
export chatter feed attachments and import to another sales force org
Hi,
I am trring to export chatter feed attachments (it is showing as content data) .
i want to export all the chatter feed attachment data and import to another salesforce org under the same chatter post.
I tried through workbench,dataloader we are getting the details but the parentid has no value, i am wondering how to relate if there is no parentid is related.can any one please help me to solve this issue.
I am trring to export chatter feed attachments (it is showing as content data) .
i want to export all the chatter feed attachment data and import to another salesforce org under the same chatter post.
I tried through workbench,dataloader we are getting the details but the parentid has no value, i am wondering how to relate if there is no parentid is related.can any one please help me to solve this issue.
-
- krishna chaitanya 35
- April 29, 2016
- Like
- 0
- Continue reading or reply
Need help to write test class for pagereference methods.
Hi Team,
I have written a controller which will redirect to opportunity defaultpage and displaying opportunity default name using pagerefernce methods.I am rying to write a test class for the same.but unable to succeed.
public with sharing class MyController123{
public MyController123(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', 'DO NOT OVERRIDE');
return pr;
}
}
@isTest
public class MyControllerTest{
static testMethod void testDefault()
{
Opportunity opp = new(Name='Test');
insert opp;
PageReference pref = Page.Oppdefaultname;
pref.getParameters().put('id',opp.name);
Test.setCurrentPage(pref);
Test.startTest();
ApexPages.StandardController con = new ApexPages.StandardController(opp);
MyController123 myc = new MyController123(con);
Test.stopTest();
}
}
Thanks,
Krishna
I have written a controller which will redirect to opportunity defaultpage and displaying opportunity default name using pagerefernce methods.I am rying to write a test class for the same.but unable to succeed.
public with sharing class MyController123{
public MyController123(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', 'DO NOT OVERRIDE');
return pr;
}
}
@isTest
public class MyControllerTest{
static testMethod void testDefault()
{
Opportunity opp = new(Name='Test');
insert opp;
PageReference pref = Page.Oppdefaultname;
pref.getParameters().put('id',opp.name);
Test.setCurrentPage(pref);
Test.startTest();
ApexPages.StandardController con = new ApexPages.StandardController(opp);
MyController123 myc = new MyController123(con);
Test.stopTest();
}
}
Thanks,
Krishna
-
- krishna chaitanya 35
- April 29, 2016
- Like
- 0
- Continue reading or reply
Create a validation rule for escalated cases.
The validation rule should be on the Case object.
The validation rule should be named 'Mark_as_Escalated'.
The validation rule should fire if someone tries to set a case as escalated and it is closed, closed when created, or does not have a priority of High.
The validation rule should display the error message 'You can only set a case as escalated if it is high priority and not closed' under the Escalated field when triggered.
Add the 'Escalated' field to the Case page layout.
The validation rule should be named 'Mark_as_Escalated'.
The validation rule should fire if someone tries to set a case as escalated and it is closed, closed when created, or does not have a priority of High.
The validation rule should display the error message 'You can only set a case as escalated if it is high priority and not closed' under the Escalated field when triggered.
Add the 'Escalated' field to the Case page layout.
-
- krishna chaitanya 35
- December 22, 2015
- Like
- 1
- Continue reading or reply
how to define product catalogs ?
Hi Team,
Is there possibility to define product catalog?
can we define product hirearchy in salesforce?
please help me on this issue?
Thanks in Advance,
Krishna.
Is there possibility to define product catalog?
can we define product hirearchy in salesforce?
please help me on this issue?
Thanks in Advance,
Krishna.
-
- krishna chaitanya 35
- November 17, 2015
- Like
- 0
- Continue reading or reply
Auto forward emails that are received to case to a outlook email id
Hi Team,
I have a scenario like i need to auto forward the emails related to a case to a outllok email .
For Ex: For Case #00001 i have a received email i need to send those emails to test@test.salesforce.com.please kindly help me how to proceed with this implementation.
Thanks in Advance,
Krishna.
I have a scenario like i need to auto forward the emails related to a case to a outllok email .
For Ex: For Case #00001 i have a received email i need to send those emails to test@test.salesforce.com.please kindly help me how to proceed with this implementation.
Thanks in Advance,
Krishna.
-
- krishna chaitanya 35
- November 09, 2015
- Like
- 0
- Continue reading or reply
Create a validation rule for escalated cases.
The validation rule should be on the Case object.
The validation rule should be named 'Mark_as_Escalated'.
The validation rule should fire if someone tries to set a case as escalated and it is closed, closed when created, or does not have a priority of High.
The validation rule should display the error message 'You can only set a case as escalated if it is high priority and not closed' under the Escalated field when triggered.
Add the 'Escalated' field to the Case page layout.
The validation rule should be named 'Mark_as_Escalated'.
The validation rule should fire if someone tries to set a case as escalated and it is closed, closed when created, or does not have a priority of High.
The validation rule should display the error message 'You can only set a case as escalated if it is high priority and not closed' under the Escalated field when triggered.
Add the 'Escalated' field to the Case page layout.
-
- krishna chaitanya 35
- December 22, 2015
- Like
- 1
- Continue reading or reply
Assign a value retrived from Map to a custom field in account
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
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
- krishna chaitanya 35
- July 19, 2020
- Like
- 0
- Continue reading or reply
footer is displayed above the content in vf pgae when it is rendered as a pdf
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"> </span>
</td>
<td width="10%" align="right">
<span class="cls_002"> {!$User.Email}</span>
</td>
</tr>
<tr>
<td width="15%">
<span class="cls_002"> </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"> </span>
</td>
</tr>
<tr>
<td>
<span class="cls_002"> </span>
</td>
<td>
<span class="cls_002">testr.testr testr</span>
</td>
<td>
<span class="cls_002"> </span>
</td>
<td>
<span class="cls_002"> </span>
</td>
</tr>
</table>
</div>
</div>
<div class="content" style="border-style: double" >
</div>
</body>
</apex:form>
</apex:page>
sample out put:
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"> </span>
</td>
<td width="10%" align="right">
<span class="cls_002"> {!$User.Email}</span>
</td>
</tr>
<tr>
<td width="15%">
<span class="cls_002"> </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"> </span>
</td>
</tr>
<tr>
<td>
<span class="cls_002"> </span>
</td>
<td>
<span class="cls_002">testr.testr testr</span>
</td>
<td>
<span class="cls_002"> </span>
</td>
<td>
<span class="cls_002"> </span>
</td>
</tr>
</table>
</div>
</div>
<div class="content" style="border-style: double" >
</div>
</body>
</apex:form>
</apex:page>
sample out put:
- krishna chaitanya 35
- February 28, 2018
- Like
- 0
- Continue reading or reply
Send a separate email to each contact
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.
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.
- krishna chaitanya 35
- February 27, 2018
- Like
- 0
- Continue reading or reply
Multiple emails are recived from singleemailmessage(Recurring Emails)
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
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
- krishna chaitanya 35
- October 24, 2017
- Like
- 0
- Continue reading or reply
VF page Doc conversion - Footeris being displayed twice on last page.
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============================

============================================================
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============================
============================================================
- krishna chaitanya 35
- September 13, 2017
- Like
- 0
- Continue reading or reply
calculate the given date minus 6 months
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.
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.
- krishna chaitanya 35
- August 21, 2017
- Like
- 0
- Continue reading or reply
images are not displaying in Visualforce page when rendered as word document and repetition of footer
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========================
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========================
- krishna chaitanya 35
- August 17, 2017
- Like
- 0
- Continue reading or reply
junction object trigger
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');
}
}
}
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');
}
}
}
- krishna chaitanya 35
- August 09, 2017
- Like
- 0
- Continue reading or reply
Javascript remoting to display a list of records in a pageblock or pageblock table
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;
}
}
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;
}
}
- krishna chaitanya 35
- May 28, 2017
- Like
- 0
- Continue reading or reply
route cases to queue(Batch Class)
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.
- krishna chaitanya 35
- March 27, 2017
- Like
- 0
- Continue reading or reply
Need help in lightning how to override standard new page in opportunity with visualforce page
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 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.
- krishna chaitanya 35
- September 14, 2016
- Like
- 0
- Continue reading or reply
how to add loading spinner on salesforce lightning component ?
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
please help thanks in advance
- developer fox
- September 02, 2016
- Like
- 0
- Continue reading or reply
Users can't see report
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.
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.
- Rajiv
- February 01, 2016
- Like
- 0
- Continue reading or reply
Running Header and Footer is repeating while rendering as a word
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 .
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 .
- Manojjena
- January 21, 2015
- Like
- 0
- Continue reading or reply
Apex trigger for OpportunityContactRole object
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
- boihue
- December 09, 2008
- Like
- 0
- Continue reading or reply
Salesforce Admin Opportunity!!
Looking for a start-up, progressive work environment, but want the stability of a company that's been around for a while? Our client is looking for a Salesforce Administrator to take charge of their Salesforce Org. The SA will oversee the day-to-day administrative tasks, as well as managing apps (and keeping them current), work with business partners to define and develop business requirements, participate and/or coordinate required testing/validation of system enhancements and fixes and coordinate with development team for resolution of defects or production issues. $90K plus benefits. If interested contact me at nancy@tech2resources.com
- Nancy@Tech2
- November 03, 2015
- Like
- 3
- Continue reading or reply