- GauravTrivedi
- NEWBIE
- 145 Points
- Member since 2014
- Senior Consultant
-
ChatterFeed
-
4Best Answers
-
0Likes Received
-
1Likes Given
-
8Questions
-
43Replies
FILE ATTATCHMENT
Hi
VFPAGE
<apex:inputFile filename="{!fileName}" value="{!resume}"/>
CONTROLLER
public String fileName {get; set;}
public Blob resume {get; set;}
private Empolyee_Details__c empDetail;
try{
if(resume!=null){
Attachment attach=new Attachment();
attach.Body=resume;
attach.Name=filename;
attach.ParentID=empDetail.id;
upsert(attach);
}
The above one is the FILE ATTATCHMENT CODE .In that code i didnt get any errors but file was not uploading .please tell me any issues are there for above code.
Thansk&Regards
RangaReddy
-
- udayarangareddy mekala
- November 18, 2015
- Like
- 0
- Continue reading or reply
-
- Mandakini Saranu
- November 05, 2015
- Like
- 0
- Continue reading or reply
Can access a field in SOQL, can't access it in Apex....?
I'm new to Apex Code / SOQL.
I'm trying to write a trigger based on someone's Mailchimp Interest Lists. I can the value I need no problem if I run SOQL directly, e.g.
select MC4SF__MC_Subscriber__r.MC4SF__Interests__c from lead where Id = '00Q24000004bfgYEAQ'
gives me the result I need:

But whatever I do I can't seem to get access to this value in Apex Code, e.g. this is the trigger:
trigger updateMCStatus on Lead (after update) { Map<String, Lead> leadMap = new Map<String, Lead>(); for (Lead lead : System.Trigger.new) { System.Debug('lead mc interests: ' + lead.MC4SF__MC_Subscriber__r.MC4SF__Interests__c); System.Debug('lead mc subscriber: ' + lead.MC4SF__MC_Subscriber__c); String query = 'select MC4SF__MC_Subscriber__r.MC4SF__Interests__c from lead where Id = \'' + String.escapeSingleQuotes(lead.Id) + '\''; System.Debug(query); List<sObject> sobjList = Database.query(query); System.Debug('object: ' + sobjList[0]); } }
Results of those debugs:
lead.MC4SF__MC_Subscriber__r.MC4SF__Interests__c = null
lead.MC4SF__MC_Subscriber__c = a0B24000004BPMnEAO
(the SOQL query) sobjList[0] = Lead:{MC4SF__MC_Subscriber__c=a0B24000004BPMnEAO, Id=00Q24000004bfgYEAQ}
Is there anything I can do to get this value :) ? It's driving me crazy.
Cheers!
Dan
-
- Dan Rogers
- November 04, 2015
- Like
- 0
- Continue reading or reply
How to send an email for Opportunities with attachment form notes and attachments?
Apex Class
public class email_class{ public email_class(ApexPages.StandardController controller) { } Public string ToAddresses {get;set;} Public string CCAddresses {get;set;} Public string opportunityId {get;set;} Public string subject {get;set;} public string email_body {get;set;} public string emailTo {get;set;} public string emailCC {get;set;} Public PageReference send(){ Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage(); // set the to address mail.setToAddresses(new String[] {emailTo}); mail.setCcAddresses(new String[] {emailCC}); //set the cc address mail.setSubject(subject); mail.setBccSender(false); mail.setUseSignature(false); mail.setPlainTextBody(email_body); mail.setWhatId(opportunityId);// Set email file attachments List<Messaging.Emailfileattachment> fileAttachments = new List<Messaging.Emailfileattachment>(); for (Attachment a : [select Name, Body, BodyLength from Attachment where ParentId = :opportunityId]){ // Add to attachment file list Messaging.Emailfileattachment efa = new Messaging.Emailfileattachment(); efa.setFileName(a.Name); efa.setBody(a.Body); fileAttachments.add(efa);} mail.setFileAttachments(fileAttachments);// Send email Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail }); return null; } }
VF page
<apex:page standardController="Opportunity" extensions="email_class"> <apex:form > <apex:pageBlock title="Email Details"> <b>To: </b> <apex:inputText value="{!emailTo}"/><p/> <b>CC: </b> <apex:inputText value="{!emailCC}" /><p/> <b>Enter Subject: </b> <apex:inputText value="{!subject}" maxlength="200"/><p/> <b>Enter Body: </b> <apex:inputTextArea value="{!email_body}" rows="10" cols="100"/><p/> <apex:pageBlock title="Attachments"> <apex:pageBlockTable value="{!opportunity.Attachments}" var="Att"> <apex:column headerValue="Select"> <apex:inputCheckbox value="{!opportunity.Send_Email_with_Quote__c}"/> </apex:column> <apex:column value="{!Att.createddate}"/> <apex:column value="{!Att.name}"/> <apex:column value="{!Att.description}"/> </apex:pageBlockTable><p/> </apex:pageblock> <apex:commandButton value="Send Email" action="{!send}"/> <apex:commandButton value="Canel" action="{!cancel}"/> </apex:pageBlock> </apex:form> </apex:page>
-
- Chelsea Lukowski
- November 04, 2015
- Like
- 0
- Continue reading or reply
sfdx force:source:deploy is not deploying WorkflowRule, and related entities
The WorkflowRule named <RULE> was not found in the workspace.
I am using below command
sfdx force:source:deploy -x ./manifest/package.xml -u orgAliasProject structure:
Project --> force-app --> main --> default --> workflows
<?xml version="1.0" encoding="UTF-8"?> <Workflow xmlns="http://soap.sforce.com/2006/04/metadata"> <fieldUpdates> <fullName>Rule_Name</fullName> <description>DESCRIPTION</description> <field>field__c</field> <literalValue>1</literalValue> <name>Name</name> <notifyAssignee>false</notifyAssignee> <operation>Literal</operation> <protected>false</protected> <reevaluateOnChange>true</reevaluateOnChange> </fieldUpdates> <rules> <fullName>Rule Name</fullName> <actions> <name>Rule_Name</name> <type>FieldUpdate</type> </actions> <active>false</active> <criteriaItems> <field>Object__c.RecordTypeId</field> <operation>equals</operation> <value>myValue</value> </criteriaItems> <description>DESCRIPTION</description> <triggerType>onCreateOrTriggeringUpdate</triggerType> </rules> </Workflow>
Project-->manifest-->package.xml
<?xml version="1.0" encoding="UTF-8"?> <Package xmlns="http://soap.sforce.com/2006/04/metadata"> <types> <members>Object__c.Rule Name</members> <name>WorkflowRule</name> </types> <types> <members>Object__c.Rule_Name</members> <name>WorkflowFieldUpdate</name> </types> <version>46.0</version> </Package>
-
- GauravTrivedi
- July 24, 2019
- Like
- 0
- Continue reading or reply
How to query AsyncResult/DeployResult records?
Any suggestions would be really helpful for me. Thanks!
-
- GauravTrivedi
- August 08, 2018
- Like
- 0
- Continue reading or reply
Sort given object in parent child fashion
- Lead
- Account
- Campaign
- Contact
- Account
- Contact
- Lead
- Campaign
Any help will be greatly appreciated. Thanks!
-
- GauravTrivedi
- March 30, 2016
- Like
- 0
- Continue reading or reply
Test Class for standard set controller
public Integer opportunityTotalPage{ get { integer total = 0; integer totalResults = StdSetControllerOpportunity.getResultSize(); if (totalResults > 0){ total = 1; if (totalResults > StdSetControllerOpportunity.getPageSize()){ total = totalResults / StdSetControllerOpportunity.getPageSize(); integer remainder = Math.mod(totalResults,StdSetControllerOpportunity.getPageSize()); if (remainder > 0){ total++; } } } return total; } set; }
If anyone have any Idea please help me out. Tks!
-
- GauravTrivedi
- January 25, 2016
- Like
- 0
- Continue reading or reply
-
- GauravTrivedi
- November 24, 2015
- Like
- 0
- Continue reading or reply
How to undelete records using Apex Batch Class.
I was trying to recover record which are accedently deleted from salesforce instance and I am using the following code:
global class BatchClass implements Database.Batchable<sObject>,Schedulable{ global Database.queryLocator start(Database.BatchableContext bc){ String query = 'SELECT Id, Name, IsDeleted, ItemName__c FROM Buffer__c WHERE IsDeleted = True ALL ROWS'; return Database.getQueryLocator(query); } global void execute(Database.BatchableContext BC, List<Buffer__c> scope){ List<Buffer__c> bufferList = new List<Buffer__c>(); for(Buffer__c s:scope){ s.ItemName__c='Gaurav'; bufferList.add(s); } system.debug('Data--->'+bufferList); undelete bufferList; } global void finish(Database.BatchableContext bc){ AsyncApexJob a = [SELECT Id, Status, NumberOfErrors, JobItemsProcessed, TotalJobItems, CreatedBy.Email FROM AsyncApexJob WHERE Id =:BC.getJobId()]; Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage(); String[] names = new String[]{a.CreatedBy.Email}; mail.setToAddresses(names); mail.setSubject('Mail: Test'); mail.setPlainTextBody('Hi ,\n\nThe following job is '+a.Status+' and jobId is '+a.Id+'\n\n\n Regards,\n'+a.CreatedBy.Email); Messaging.sendEmail(new Messaging.SingleEmailMessage[]{mail}); } global void execute(SchedulableContext s){ Database.executeBatch(this); } }
When I am trying to execute my batch class it doesnt undelete records from recycle bin. Can anyone please help me out. Thanks!
-
- GauravTrivedi
- October 22, 2015
- Like
- 0
- Continue reading or reply
Salesforce Azure Integration, Error in getting token
I am trying to integrate salesforce and some application via azure service bus. Code i used is:
Http h = new Http();
HttpRequest req = new HttpRequest();
// ** Getting Security Token from STS
String Url = 'https://XXXX.accesscontrol.windows.net/WRAPv0.9/';
// String encodedPW = EncodingUtil.urlEncode([password]', 'UTF-8');
req.setEndpoint(Url);
req.setMethod('POST');
req.setBody('wrap_name=SenderTest&wrap_password=XXXXX==&wrap_scope=http://XXXX.servicebus.windows.net/MenuService');
req.setHeader('Content-Type','application/x-www-form-urlencoded');
HttpResponse res = h.send(req);
result = res.getBody();
And I am getting result =
Error:Code:400:SubCode:T0:Detail:ACS90004: The request is not properly formatted.:TraceID:848b16db-dd8c-406e-8239-d96428e70f11:TimeStamp:2014-05-13 11:39:31Z
I am not able to get token. please help me out for the same...
-
- GauravTrivedi
- May 13, 2014
- Like
- 0
- Continue reading or reply
By Default which sharing rule will apply on Apex??
-
- GauravTrivedi
- February 25, 2014
- Like
- 0
- Continue reading or reply
How to query AsyncResult/DeployResult records?
Any suggestions would be really helpful for me. Thanks!
- GauravTrivedi
- August 08, 2018
- Like
- 0
- Continue reading or reply
VF Page in Edit and Create Mode
- Raghu Sharma 6
- March 30, 2016
- Like
- 0
- Continue reading or reply
how to check the old lead status with new lead lead status in apex class
i have the method where i will check the lead (lead records related to group members) owners and status is not changed with in 24 hoursthen i will update the checkbox__x to true.
Currently i have written the code until fetching the leads related to particulr public group of test_Team.Please suggest me how to check the existed old status with new lead status in apex class to process furthur.
public static void updateNamercheckbox(List<Lead> allleadlist){
set<id> useridset=new set<id>();
set<id> leadid=new set<id>();
for(Lead led:allleadlist){
leadid.add(led.ownerId);
}
List<Group> pbgrpid = [select id from Group where type='Regular' AND DeveloperName='test_Team'];
List<GroupMember> userids = [select UserOrGroupId,GroupId from GroupMember where GroupId IN:pbgrpid];
for(GroupMember gmid:userids){
useridset.add(gmid.UserOrGroupId);
}
system.debug('useridset' +leadid);
}
}
- Abi V 4
- March 30, 2016
- Like
- 0
- Continue reading or reply
needs previous value record in current records filed using triggers on and using salesforce admin
Hi
I have a below requirement,
I have created an object for calculating mileage vs cost for bike
I have the below fields in my object:
Object Name:
API NameMileage_vs_Cost__c
Bill AmountBill_Amount__c
Current ReadingCurrent_Reading__c
DateDate__c
Past ReadingPast_Reading__c
PetrolUserName__c
Petrol User is a master object for( Mileage_Vs_ Cost__c) object
Example : For the first time when I save my record, current reading is zero fueled on 3/21/2016,
I will be travelling whole month and next time when I am ready to fuel the petrol , I will be entering some 1000 kms as current reading and when I do this process I want the past reading(i.e; previous month's current reading which is 0(zero) when I filled fuel on 3/21/2016) to get populated in Past_reading__c filed of my record….
So that I can calculate mileage = (Current reading - past reading) and based on this further developments I can do on the page; can any one help me in this requirement I feel grateful and I am trying it using List and triggers and am failing…
- DILEEP NALLA
- March 21, 2016
- Like
- 0
- Continue reading or reply
how to call string.valueof() in a test class
Trigger :
trigger UpdateRenewableFields on Contract(after insert) { Set<Id> oliIds = new Set<Id>(); Map<string, Contract> contractMap = new Map<string, Contract>(); List<OpportunityLineItem> oliIdsToUpdate = new List<OpportunityLineItem>(); for(Contract c: Trigger.new) { if(c.Opportunity_Product_Id__c != null && c.Opportunity_Product_Id__c != '') { oliIds.add(c.Opportunity_Product_Id__c); if(c.Parent_Opportunity_Product_Id__c != null && c.Parent_Opportunity_Product_Id__c != '') { contractMap.put(c.Parent_Opportunity_Product_Id__c , c); } } } if(oliIds.size() > 0) { //Get Parent OLI Ids// List<OpportunityLineItem> parentOliList = [Select Id,Parent_Opportunity_Product_Id__c, Contract__c from OpportunityLineItem where Id in: oliIds]; Set<Id> parentOlis = new Set<Id>(); Map<Id, OpportunityLineItem> oliMap = new Map<Id, OpportunityLineItem>(); for(OpportunityLineItem oli:parentOliList) { oliMap.put(oli.id, oli);///Map use to update OLI parentOlis.add(oli.Parent_Opportunity_Product_Id__c); } List<Contract> parentContractList = [Select Id,Renewal_Contracts_Numbers__c,Opportunity_Name__c,Opportunity_Product_Id__c, Renewal_Status__c,Renewal_Amount__c,Renewal_ARR__c from Contract where Opportunity_Product_Id__c in: parentOlis]; List<Contract> contractsToUpdate = new List<Contract>(); for(Contract parent: parentContractList) { if(parent.Opportunity_Product_Id__c != null && parent.Opportunity_Product_Id__c != '' && contractMap.containsKey(String.valueOf(parent.Opportunity_Product_Id__c))) { Contract child = contractMap.get(String.valueOf(parent.Opportunity_Product_Id__c)); //parent.Renewal_Contract__c = true ; parent.Renewal_Contracts_Numbers__c = child.Id ; parent.Renewal_Status__c = 'Renewed'; parent.Renewal_Amount__c = child.Subtotal_Price__c ; parent.Renewal_ARR__c = child.Annual_Recurring_Revenue__c ; if(parent.Multi_year_Sub_extension_contract__c) { parent.Actual_renewal_date__c = child.Actual_renewal_date__c; } contractsToUpdate.add(parent); } } System.debug('contractsToUpdate::' + contractsToUpdate); ///Updating Opportunity Line Item with Contract Number//// for(Contract c: Trigger.new) { if(oliMap.containsKey(c.Opportunity_Product_Id__c)) { OpportunityLineItem oli = oliMap.get(c.Opportunity_Product_Id__c); oli.Contract__c = c.Id; oliIdsToUpdate.add(oli); } } ///////////////////////////////////////////////////////// try { if(contractsToUpdate.size() > 0) { update contractsToUpdate; } if(oliIdsToUpdate.size() > 0) { update oliIdsToUpdate; } } catch(Exception e) { System.debug('ERROR::' + e.getMessage()); } } }Test Class :
@IsTest public class TestUpdateRenewableFields{ static testmethod void testUpdateRenewable(){ Account acc10 = new Account(Name='Testing SubscriptionClone', BillingStreet='Banjara hills', BillingCity='Hyd', BillingState='TS', BillingPostalCode = '500084', BillingCountry = 'India', Phone = '100', Industry = 'Banking', Type = 'Paid', Customer_Type__c = 'Customer', Customer_List__c = true,PPAS__c = false, PPCD__c = false,PPSP__c = false, PGSQL__c = false,PPAS_Developer_Sub__c = false, PPSP_Developer_Sub__c = false, PGSQL_Developer_Sub__c = false,RDBA__c = false, Services__c = false,Training__c = false,SteelEye__c = false,Jump_Start_Subscription__c = false ); insert acc10 ; contact cc10 = new contact(FirstName ='Test Contact Subscription', LastName ='Opptyclone', Role__c='Subscription Administrator',AccountId=acc10.Id); insert cc10; Opportunity opty10 = new Opportunity(Name = 'Test SubscriptionOppty', StageName ='Proposal/Price Quote', Probability =60, CloseDate = System.Today(), Type = 'Existing Customer', Assigned_Sales_Engineer__c = null, Update_Complete__c = true, Partner__c = 'None', Anchor__c='Non Anchor', AccountId = acc10.Id, Payment_Type__c = 'Order Form', LeadSource = 'Subscription Renewal'); insert opty10; list<OpportunityContactRole> opptyConRolelist15 = new list<OpportunityContactRole>{ new OpportunityContactRole(ContactId = cc10.Id, OpportunityId = opty10.Id, IsPrimary = false, Role = 'Subscription Administrator') }; insert opptyConRolelist15; product2 p2 = new product2(Name ='Postgres Plus Enterprise Edition Unicores', Product_Name1__C='Product - Subscription', Product_Group__c='PPAS', IsActive = true, Description='Postgres Plus Enterprise Edition Unicores', ARR_Impact1__c = 'Yes'); insert p2; PricebookEntry pbey = new PricebookEntry(Product2ID=p2.id, Pricebook2ID= test.getStandardPricebookId(), UnitPrice=50, isActive=true); insert pbey; Opportunitylineitem ooli10 = new Opportunitylineitem(OpportunityId = opty10.Id, PricebookEntryId = pbey.Id, Quantity =4, Start_Date__c = System.today(), End_Date__c = System.today() + 100, Type_of_Contract__c='None', Term__c =12, Type_Of_Product__c='Single Year Subscription', Type_of_ARR__c= 'New Addition ARR', TotalPrice=1750, No_ARR__c = false, In_Year_Billing__c = 10); insert ooli10; Opportunitylineitem ooli15 = new Opportunitylineitem(OpportunityId = opty10.Id, PricebookEntryId = pbey.Id, Quantity =4, Start_Date__c = System.today(), End_Date__c = System.today() + 100, Type_of_Contract__c='None', Term__c =12, Type_Of_Product__c='Single Year Subscription', Type_of_ARR__c= 'New Addition ARR', TotalPrice=1750, No_ARR__c = false, In_Year_Billing__c = 10, Parent_Opportunity_Product_Id__c=ooli10.Id); insert ooli15; // list<Contract> contrlist = new list<Contract>{ Contract contrlist= new Contract(CurrencyIsoCode='USD', Annual_Contract_Value__c =5000, Type_Of_Product__c='Single Year Subscription', Notes__c='Contract is getting created', Opportunity_Product_Id__c= ooli10.Id, Contracts_In_Year_Billing__c=1500, AccountId=acc10.Id); insert contrlist; Contract contr1 = new Contract(CurrencyIsoCode='USD', Annual_Contract_Value__c =5000, Type_Of_Product__c='Single Year Subscription', Notes__c='Contract is getting created', Opportunity_Product_Id__c= ooli10.Id, Contracts_In_Year_Billing__c=1500, AccountId=acc10.Id); insert contr1; Test.StartTest(); contrlist.Renewal_Contracts_Numbers__c=contr1.id; contrlist.Renewal_ARR__c=contr1.Annual_Recurring_Revenue__c; contrlist.Renewal_Amount__c=contr1.Subtotal_Price__c; contrlist.Renewal_Status__c='Renewed'; update contr1; Test.StopTest(); } }The lines which are not getting covered :
{ if(parent.Opportunity_Product_Id__c != null && parent.Opportunity_Product_Id__c != '' && contractMap.containsKey(String.valueOf(parent.Opportunity_Product_Id__c))) { Contract child = contractMap.get(String.valueOf(parent.Opportunity_Product_Id__c)); //parent.Renewal_Contract__c = true ; parent.Renewal_Contracts_Numbers__c = child.Id ; parent.Renewal_Status__c = 'Renewed'; parent.Renewal_Amount__c = child.Subtotal_Price__c ; parent.Renewal_ARR__c = child.Annual_Recurring_Revenue__c ; if(parent.Multi_year_Sub_extension_contract__c) { parent.Actual_renewal_date__c = child.Actual_renewal_date__c; } contractsToUpdate.add(parent); } }Any help very much appreciated.
- SalesforceCrm AccountCRM
- March 21, 2016
- Like
- 0
- Continue reading or reply
Report to FTP
I like to place my Report on FTP folder automatically on weekly basis and my report wont exceed 10 MB size, i tried dataloader:io but it didnt help me to schedule on weekly basis, in dataloader i can schedule daily only for free version.My requirement is to place only one report otherwise i go for paid version.
Please suggest me if you have any free tool and some feasible solution.
thanks
soma
- soma s 6
- March 21, 2016
- Like
- 0
- Continue reading or reply
Trigger failing on live but works on sandbox
I have deployed a trigger to live but it seems to not populate the service Contract but in sandbox it does.
The name of the fields are the same. The trigger is
I have tested the below on our test system and it works correctly. The fields are the same in Live and Sandbox but the trigger will not populate the service contract field on a case.
I have tried removing the recordtype, using specific account but no luck on Live.
trigger UpdateServiceContract on Case (before insert,before update, after update) {
if (trigger.isBefore && trigger.isInsert) {
for (Case c : trigger.new) {
if (c.RecordTypeID == '012D0000000NWyPIAW')
if (c.service_contract__c == NULL){
try{
//c.Service_Contract__c = [select Id from ServiceContract where AccountId ='810D0000000Cfza' and Primary_Service_Contract__c = True].id;
c.Service_Contract__c = [select Id from ServiceContract where AccountId = :c.AccountId and Primary_Service_Contract__c = True limit 1].id;
}catch(QueryException e) {
//No records found. Maybe you should set it to Null
}
}
}
}
}
Is there a trigger log
- Peter Cowen
- March 18, 2016
- Like
- 0
- Continue reading or reply
- GauravTrivedi
- November 24, 2015
- Like
- 0
- Continue reading or reply
Test Class passing but not covering the Parent class always the coverage is 0%
Class
global class ABfutureclass {
@future
public static void createABdetails(){
string timePSetName=Label.Time;
PermissionSet timePSet =[SELECT Id,IsOwnedByProfile,Label FROM PermissionSet where Name=:timePSetName limit 1];
Id myID2 = userinfo.getUserId();
string permissionsetid = timePSet.id;
List<PermissionSetAssignment> lstPsa = [select id from PermissionsetAssignment where PermissionSetId =: permissionsetid AND AssigneeId =:myID2];
if(lstPsa.size() == 0)
{
PermissionSetAssignment psa1 = new PermissionsetAssignment(PermissionSetId= permissionsetid, AssigneeId = myID2 );
database.insert(psa1);
}
}
}
Test Class
@isTest
public class ABfutureclasstest {
public static testMethod void createABdetails(){
test.startTest();
Profile Profile1 = [SELECT Id, Name FROM Profile WHERE Name = 'Basic Profile'];
User u = [SELECT Id FROM User WHERE ProfileId =:Profile1.Id AND isActive = true LIMIT 1];
PermissionSet ps = [SELECT Id FROM PermissionSet WHERE Name =: Label.Time];
system.runAs(u){
PermissionSetAssignment psa = new PermissionSetAssignment();
psa.AssigneeId = u.Id;
psa.PermissionSetId = ps.Id;
insert psa;
}
test.stopTest();
}
}
- Ravi23
- November 19, 2015
- Like
- 0
- Continue reading or reply
Workflow rule criteria formula help
I'm creating a workflow that I'd like to trigger when a Billing Contact is updated - not when one is added for the first time and not when it is changed to a blank text value. I had the following formula, but it's triggering when it changes from blank to a name and I just want it to trigger when it changes from one name to another name. Let me know if I can provide any more information, thanks!
AND(ISCHANGED(Billing_Contact__c )
- Vicky Pan
- November 18, 2015
- Like
- 0
- Continue reading or reply
FILE ATTATCHMENT
Hi
VFPAGE
<apex:inputFile filename="{!fileName}" value="{!resume}"/>
CONTROLLER
public String fileName {get; set;}
public Blob resume {get; set;}
private Empolyee_Details__c empDetail;
try{
if(resume!=null){
Attachment attach=new Attachment();
attach.Body=resume;
attach.Name=filename;
attach.ParentID=empDetail.id;
upsert(attach);
}
The above one is the FILE ATTATCHMENT CODE .In that code i didnt get any errors but file was not uploading .please tell me any issues are there for above code.
Thansk&Regards
RangaReddy
- udayarangareddy mekala
- November 18, 2015
- Like
- 0
- Continue reading or reply
Removing '-' from phone number field which is of type String
I've a field for Phone number of type String. And the format of it would be 111-222-3333. I want to remove the '-' from it and it should look like 1112223333. Please suggest me a validation rule or formula to achieve this.
Thanks,
vasavi
- Vasavi Vajinepalli
- November 18, 2015
- Like
- 0
- Continue reading or reply
Create a multipage Word document with header and footer
I have to create a multipage word document, which have company logo in header and page number in footer.
For a doc, header is same for each page. But the company logo is dynamic, depends on for which company i have to create the document.
The document is also rich formatted, means contains several tables etc.
Two approaches i have used.
a) Create a VF page and specify the contentType as 'application/msword'.
b) Use word template with mail merge feature.
a) Create a VF page and specify the contentType as 'application/msword'.
-----------------------------------------------------------------------------------------------------
a large single page document is created (I am using word 2010), instead of a multi page document. when i opened that in open office it is a multi page documnet. but header is appearing only on first page and footer on last page.
I have found that it is too difficult to add styling in this approach, because word is not supporting page's css. Main issue
is with headers and footers.
b) Use word template with mail merge feature.
------------------------------------------------------------------
standard Mail merge is not supported on firefox. salesforce mail merge is not worked with Word 2010 also.
word template created with word 2007 is only supported. but with that also i am not successful to insert image in
merge_field.
create a textfield with absolute url of the image. than create a merge field on the template for that. but the url is placed
in the generated word document using mail merge.
I have a second approach for that. Use 'INCLUDEPICTURE' as follows
{INCLUDEPICTURE "<<merge_field>>"}, but it file not found error.
when used {INCLUDEPICTURE "url"} it succedded.
several other variations used with {INCLUDEPICTURE "<<merge_field>>"}, but no success.
I am totally confused, which approach i must follow to achieve the expected.
Thanks
- hemantgupta
- August 07, 2010
- Like
- 0
- Continue reading or reply
Dependency Picklist Rerender Issues
Account_Review__c has three picklist fields, and there are dependency rules defined between them, so options for one field, depends on whats selected in the other.
I am tryign to display the values of these three fields, in a pageblock. But its causing multiple rerenders, because of dependency picklists, and therefore showing wrong results.
Ex. I set values in three fields, and then if i change the first picklist value, the values in second and third picklist shows NULL (per dependency rules) in the dropdown, but doesnt show NULL when i am printing in the page block. See attached images.
What should i do so the values in pageblock, alwasy show the correct picklist values, after rerender. Thanks.
<apex:page standardController="Account_Review__c"> <apex:form> <apex:pageBlock> <apex:inputfield value="{!Account_Review__c.Reason__c}" id="f1"> <apex:actionSupport event="onchange" reRender="Block1"/> </apex:inputField> <apex:inputfield value="{!Account_Review__c.Result__c}" id="f2"> <apex:actionSupport event="onchange" reRender="Block1"/> </apex:inputField> <apex:inputfield value="{!Account_Review__c.Action__c}" id="f3"> <apex:actionSupport event="onchange" reRender="Block1"/> </apex:inputField> </apex:pageBlock> <apex:pageBlock id="Block1"> <apex:outputLabel >{!Account_Review__c.Reason__c}</apex:outputLabel><BR/> <apex:outputLabel >{!Account_Review__c.Result__c}</apex:outputLabel><BR/> <apex:outputLabel >{!Account_Review__c.Action__c}</apex:outputLabel><BR/> </apex:pageBlock> </apex:form> </apex:page>
- Sidharth
- October 14, 2015
- Like
- 1
- Continue reading or reply