• GauravTrivedi
  • NEWBIE
  • 145 Points
  • Member since 2014
  • Senior Consultant

  • Chatter
    Feed
  • 4
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 8
    Questions
  • 43
    Replies


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

Hi,

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:

User-added image
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



 
I have created a Visualforce page and Apex Class to be able to send an email from an Opportunity with Attachments that are in the Notes & Attachments section. The page allows them to pick an attachment to send with the email. The email will send but does not include the attachment. I know I am missing something, any help would be appriciated.

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>

 
When I try to deploy WorkflowRule, WorkflowFieldUpdate, WorkflowTask, WorkflowAlert, and WorkflowOutboundMessage I am getting below error.
The WorkflowRule named <RULE> was not found in the workspace.

I am using below command
sfdx force:source:deploy -x ./manifest/package.xml -u orgAlias
Project 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>
I was thinking to create a mechanism which will give information about the deployment statuses using Metadata API. But I stuck at the point where I am not able to query records related to AsyncResult/DeployResult. I don't know whether it is possible or not.
Any suggestions would be really helpful for me. Thanks!
I have given number of objects in set need to order them according to their lookup objects. For example, I have a set of following objects:
  1. Lead
  2. Account
  3. Campaign
  4. Contact
From the above object I have to find their refrence fields and then create a set from parent to their child, like this:
  1. Account
  2. Contact
  3. Lead
  4. Campaign
I am using Schema class to find their refrences but not able to sort then in the proper order.
Any help will be greatly appreciated. Thanks!
I was trying to cover my controller class where I used standard set controller but I stuck to cover the folowing code;
 
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!
Hi, 
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!
Hi,

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...
In class declaration if we don’t write keyword “with sharing” then it runs in system mode then why keyword “without sharing” is introduced in apex?
I was thinking to create a mechanism which will give information about the deployment statuses using Metadata API. But I stuck at the point where I am not able to query records related to AsyncResult/DeployResult. I don't know whether it is possible or not.
Any suggestions would be really helpful for me. Thanks!
I need to create a VF Page for Account for creating, viewing and editing records. What is the best approach to handle the fields for opening them for edit and view only mode? Can we use the same VF page to handle all the scenarios? How to code controller logic to handle multiple scnearios(save, edit and view)?
public with sharing class SendNamerFinacialSdlGroup{
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);
    
}
}
User-added image


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…
Can any one help me out.The code coverage is getting low.In the code i have a String.value of(),how to call this in a test class.Any help very much appreciated.
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.


 

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

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
 

 

Hi All I have a futre class and I have written a test class for the same which is passing but the parent class is just not covering any percent. Can some one hellp. Below is class and the test class.

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();
    }

}
  • November 19, 2015
  • Like
  • 0
Hey all,

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 )


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

Hi,

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 

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

Hello,

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>
User-added imageUser-added image