• krishn chaithanya
  • NEWBIE
  • 15 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 3
    Replies
how to avoid duplicate records based on owner role, and not show duplicate usernames in page block table . can any one help me we have multiple member roles(CC owner, member, viewer)based on roles member should be unique in the page block table. Highest priority should be CC owner.

Vf page:
<apex:pageBlock title="Members">
<apex:pageBlockButtons location="top" >
<apex:commandButton value="Addmember" action="{!newMember}"/>
</apex:pageBlockButtons>
<apex:pageBlockTable value="{!members}" var="mi" columnsWidth="200,200,100,*">
<apex:column headerValue= Name">
<apex:commandLink value="{!mi.ProjUsers__r.name}" action="{!gotoMemberEdit}">
<apex:param name="mbrId" value="{!mi.Id}"/>
</apex:commandLink>
<apex:outputText value="{!mi.ProjUsers__r.name}"
</apex:column>
<apex:column value="{!mi.ProjUsers__r.email}" id="text" headerValue="Email"/>
<apex:column value={!mi.Role__c}" headerValue="Role"/>
</apex:pageBlockTable>
<apex:pageBlockTable value="{!parentmembers}" var="pmi">
<apex:column value="{!pmi.Costcentre__r.cc_Owner__c}" headerValue="Parent"/>
<apex:column value="{!pmi.Costcentre__r.Email__c}" headerValue="Email"/>
<apex:column headerValue="Role" title="{!pmi.Costcentre__r.name}">CC Owner</apex:column>
</apex:pageBlockTable>
</apex:pageBlock>

Controller :
Public PageReference newmember(){
membs= [Select ProjMembers__c, musqot__Email_del__c ,ProjUsers__c, SubProjMembers__c, Role__c, Type__c, User_Email__c FROM Members__c where ProjMembers__c=:workId limit 1];
PageReference memberobj=new PageReference('/apex/memberobj?planid='+EncodingUtil.urlEncode(workId,'UTF-8')); memberobj.setredirect(true);
return memberobj;
}
public List<Members__c > getmembers(){ return [Select id, ProjMembers__c, musqot__ProjUsers__r.email ,ProjUsers__c,ProjUsers__r.name, SubProjMembers__c, Role__c, Type__c FROM Members__c where ProjMembers__c=:workId AND SubProjMembers__c=null];
}
public list<musqot__Allocation_amount__c > getparentmembers(){
return [Select musqot__Costcentre__r.musqot__cc_Owner__c,Costcentre__r.name,Costcentre__r.musqot__Email__c from musqot__Allocation_amount__c where Costcentre__c <> null and musqot__To_Plan__c =:workId limit 100];
}
 
Hi all,
        I am working on an app which we plan to publish on app exchange. previously we did managed package and done one major release(v1.6).at this time post install script class is aded. then after we will plan to release another version at this time we have created one custom setting object in that we have created record and did another major release(v1.7).

But, new installation of this package is working fine, when we upgraded the package from (v1.6-v1.7) at this time custom setting object record is not upgraded.
How to resolve the issue any one can suggest me ...
      
I am working on an app which we plan to publish on app exchange. As per pre-requisite requirement by salesforce, any app before getting listed on app exchange should go through code review from checkmarx.we submitted our code base to checkmarx and get one of warning reported by checkmarx. The error says "Bulkify Apex Methods - Using Collections in methods".
I'm getting checkmarx warning below line:
public void sendEmail(Purchase_order__c orders,Attachment attachment){

Here i'l update my Class:
public with sharing class PurchaseorderContrllor {
    private ApexPages.StandardController sc;
    public String projectid{get;set;}
    public String subprojectid{get;set;}
    public String purchaseordersId{get;set;}
    public String markID{get;set;}
    public string contenttype{get;set;}
    public decimal a1{get;set;}
    public string a2{get;set;}
    public string a3{get;set;} 
    public musqot__Purchase_order_setting__c pos{get;set;}
    public integer i; 
    public List<Purchase_article__c> PA_Temp = new List<Purchase_article__c>();
    public Purchase_order__c orders{get;set;}
    public Static Boolean notWildInvoicePurchOrdr;
    public PurchaseorderContrllor (ApexPages.StandardController controller) {
        This.sc = sc; 

        projectid = ApexPages.currentPage().getParameters().get('planid');   
        subprojectid= ApexPages.currentPage().getParameters().get('prjId'); 
        markID=ApexPages.currentPage().getParameters().get('markID');  
        orders= new Purchase_order__c ();
        orders.Project__c= projectid;  
        orders.subproject__c= subprojectid;
        orders.Marketing_activity__c=markID;          
    }
    
    public List<SelectOption> PAList
    {
        get
        {
            PA_Temp = [Select u.Name, u.Id From Purchase_article__c u order by u.Name limit 250];
            PAList = new List<SelectOption>(); 
            for(Purchase_article__c temp : PA_Temp)
            {
                PAList.add(new SelectOption(temp.Id, temp.Name));
            }
            return PAList;
        }
        set;
    }
    
    public Pagereference insertOrders(){
        integer i;
        try{
            if (Purchase_order__c.sObjectType.getDescribe().isCreateable())
            {
                notWildInvoicePurchOrdr = true;
                pos=[select id,PO_Startnumber__c,musqot__PO_Lastnumber__c ,musqot__PO_Prefix__c from musqot__Purchase_order_setting__c limit 250];
                if (pos.musqot__PO_Prefix__c!=null){                
                a1=pos.musqot__PO_Lastnumber__c+1;
                a2=pos.musqot__PO_Prefix__c;      
                a3=a2 +''+''+''+a1;
                orders.musqot__Purchase_order_name__c=a3;      
                  }        
                else{
                a1=pos.musqot__PO_Lastnumber__c+1;
                a2 =''+a1;
                orders.musqot__Purchase_order_name__c = a2;
                }
                               
                insert orders;
                
                i=[select count() from musqot__Purchase_order__c limit 250];
                if(i==i++){
                    pos=[select id,PO_Startnumber__c,musqot__PO_Lastnumber__c ,musqot__PO_Prefix__c from musqot__Purchase_order_setting__c limit 250];
                    pos.musqot__PO_Lastnumber__c=a1 ;
                    
                    update pos;
                }
                
            }           
            //Attachment Code
            User u = [select Id from user where id=:userinfo.getuserid()];
            
            attachment.OwnerId = u.Id;
            attachment.ParentId = orders.Id; // the record the file is attached to
            //attachment.OwnerId = u.id;
            attachment.ContentType=contentType;
            if(attachment.body<>null){
                if (Schema.sObjectType.Attachment.fields.body.isCreateable()){
                
                    attachment.Name = orders.Purchase_order_name__c;
                    //attachment.Body=null;
                    insert attachment;                     
                }                  
            }
            sendEmail(orders,attachment);
           
            Pagereference PR;
            if(subprojectid<>null){  
                String tabId = System.currentPageReference().getParameters().get('tabId');
                string pageRef='/apex/SubProject?id='+EncodingUtil.urlEncode(subprojectid,'UTF-8')+'&tab='+EncodingUtil.urlEncode('purchase','UTF-8');
                pr=new Pagereference (pageRef);              
                // PR = new Pagereference('/apex/SubProject?id='+EncodingUtil.urlEncode(subprojectid,'UTF-8'));
            }
            else if(projectid<>null)
            {
                String tabId = System.currentPageReference().getParameters().get('tabId');
                string pageRef='/apex/ProjectDetails?id='+EncodingUtil.urlEncode(projectid,'UTF-8')+'&tab='+EncodingUtil.urlEncode('purchase','UTF-8');
                pr=new Pagereference (pageRef);
                //PR = new Pagereference('/apex/ProjectDetails?id='+EncodingUtil.urlEncode(projectid,'UTF-8'));
            }
            else if(markID<>null)
            {
                String tabId = System.currentPageReference().getParameters().get('tabId');
                string pageRef='/apex/Marketingactivity?id='+EncodingUtil.urlEncode(markID,'UTF-8')+'&tab='+EncodingUtil.urlEncode('purchase','UTF-8');
                pr=new Pagereference (pageRef);
                // PR = new Pagereference('/apex/Marketingactivity?id='+EncodingUtil.urlEncode(markID,'UTF-8'));
            }
            return PR;
        }
        catch(Exception e){
            return null;
        }
    }
   public Attachment attachment {
        get {
            if (attachment == null)
                attachment = new Attachment();
            return attachment;
        }
        set;
    }
    Public Pagereference cancel(){
        
        Pagereference PR;
           if(projectid<>null)
        {
            String tabId = System.currentPageReference().getParameters().get('tabId');
            string pageRef='/apex/ProjectDetails?id='+EncodingUtil.urlEncode(projectid,'UTF-8')+'&tab='+EncodingUtil.urlEncode('purchase','UTF-8');
            pr=new Pagereference (pageRef);
            // PR = new Pagereference('/apex/ProjectDetails?id='+EncodingUtil.urlEncode(projectid,'UTF-8'));
        }
        
      else  if(subprojectid<>null)
        {
            String tabId = System.currentPageReference().getParameters().get('tabId');
            string pageRef='/apex/SubProject?id='+EncodingUtil.urlEncode(subprojectid,'UTF-8')+'&tab='+EncodingUtil.urlEncode('purchase','UTF-8');
            pr=new Pagereference (pageRef);
            //PR = new Pagereference('/apex/SubProject?id='+EncodingUtil.urlEncode(subprojectid,'UTF-8'));
        }
       
        else if(markID<>null)
        {
            String tabId = System.currentPageReference().getParameters().get('tabId');
            string pageRef='/apex/Marketingactivity?id='+EncodingUtil.urlEncode(markID,'UTF-8')+'&tab='+EncodingUtil.urlEncode('purchase','UTF-8');
            pr=new Pagereference (pageRef);
            //PR = new Pagereference('/apex/Marketingactivity?id='+EncodingUtil.urlEncode(markID,'UTF-8'));
        }
        
        return PR;
    }       
    public String getRedirectToTemplate() {
        return null;
    }
    public Purchase_order__c  templateInfo {get; set;}
    public Pagereference redirectToTemplate() {
        try{
            insert templateInfo;
        }catch(Exception e){
            ApexPages.addMessages(e);
        }
        return null;
    }    
    public void sendEmail(Purchase_order__c orders,Attachment attachment){
        if(orders.Send_date__c ==System.today() && orders.musqot__Supplier_email__c != null && orders.musqot__Supplier_email__c != ''){ 
            Purchase_order__c  purchOrdr = [SELECT Id,musqot__Purchase_order_name__c,Name,musqot__Total_cost__c,musqot__Description__c, OwnerId FROM Purchase_order__c WHERE Id = :orders.Id];
            EmailTemplate template = [SELECT Id, name,Subject, HtmlValue, Body FROM EmailTemplate WHERE name= 'Purchaseorder'];
            //Contact cnt = [select id from Contact where email != null limit 1];
            Contact cnt = new Contact();
            cnt.LastName = 'Supplier';
            cnt.Email = orders.musqot__Supplier_email__c;
            insert cnt;
            Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
            mail.setWhatId(purchOrdr.Id);
            mail.setTargetObjectId(cnt.Id);
            mail.setTemplateId(template.Id);
            mail.saveAsActivity = false;
          
              if(attachment.body<>null){
                //Set email file attachments
                List<Messaging.Emailfileattachment> fileAttachments = new List<Messaging.Emailfileattachment>();
                // Add to attachment file list
                Messaging.Emailfileattachment efa = new Messaging.Emailfileattachment();
                efa.setFileName(attachment.Name);
                efa.setBody(attachment.Body);
                efa.setContentType(attachment.ContentType);
                fileAttachments.add(efa);
                mail.setFileAttachments(fileAttachments);
            }
            //Send email
            Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail }); 
            delete cnt;           
        }       
     }
 }



In the class i didn't use any where soql query's and DML statemets inside for loops, but still i'l get bulkify apex methods warning from this line...
public void sendEmail(Purchase_order__c orders,Attachment attachment){............
I have updated my controller, can u pls tell me from where i did wrong in my code??????
 
Hi all,
        we did managed package and we have to add approval email templates in the package.But we have approval post template to display home page chatter approval fields.For these purpose we have to add in the package.in the package components list i didn't find 'approval post template' option.

So,end user every time not create approval post template manually...

Is it possible to add approval poast template in managed package?
if possible how can we achive this issue????



 
I am working on an app which we plan to publish on app exchange. As per pre-requisite requirement by salesforce, any app before getting listed on app exchange should go through code review from checkmarx.we submitted our code base to checkmarx and get one of warning reported by checkmarx. The error says "Bulkify Apex Methods - Using Collections in methods".
I'm getting checkmarx warning below line:
public void sendEmail(Purchase_order__c orders,Attachment attachment){

Here i'l update my Class:
public with sharing class PurchaseorderContrllor {
    private ApexPages.StandardController sc;
    public String projectid{get;set;}
    public String subprojectid{get;set;}
    public String purchaseordersId{get;set;}
    public String markID{get;set;}
    public string contenttype{get;set;}
    public decimal a1{get;set;}
    public string a2{get;set;}
    public string a3{get;set;} 
    public musqot__Purchase_order_setting__c pos{get;set;}
    public integer i; 
    public List<Purchase_article__c> PA_Temp = new List<Purchase_article__c>();
    public Purchase_order__c orders{get;set;}
    public Static Boolean notWildInvoicePurchOrdr;
    public PurchaseorderContrllor (ApexPages.StandardController controller) {
        This.sc = sc; 

        projectid = ApexPages.currentPage().getParameters().get('planid');   
        subprojectid= ApexPages.currentPage().getParameters().get('prjId'); 
        markID=ApexPages.currentPage().getParameters().get('markID');  
        orders= new Purchase_order__c ();
        orders.Project__c= projectid;  
        orders.subproject__c= subprojectid;
        orders.Marketing_activity__c=markID;          
    }
    
    public List<SelectOption> PAList
    {
        get
        {
            PA_Temp = [Select u.Name, u.Id From Purchase_article__c u order by u.Name limit 250];
            PAList = new List<SelectOption>(); 
            for(Purchase_article__c temp : PA_Temp)
            {
                PAList.add(new SelectOption(temp.Id, temp.Name));
            }
            return PAList;
        }
        set;
    }
    
    public Pagereference insertOrders(){
        integer i;
        try{
            if (Purchase_order__c.sObjectType.getDescribe().isCreateable())
            {
                notWildInvoicePurchOrdr = true;
                pos=[select id,PO_Startnumber__c,musqot__PO_Lastnumber__c ,musqot__PO_Prefix__c from musqot__Purchase_order_setting__c limit 250];
                if (pos.musqot__PO_Prefix__c!=null){                
                a1=pos.musqot__PO_Lastnumber__c+1;
                a2=pos.musqot__PO_Prefix__c;      
                a3=a2 +''+''+''+a1;
                orders.musqot__Purchase_order_name__c=a3;      
                  }        
                else{
                a1=pos.musqot__PO_Lastnumber__c+1;
                a2 =''+a1;
                orders.musqot__Purchase_order_name__c = a2;
                }
                               
                insert orders;
                
                i=[select count() from musqot__Purchase_order__c limit 250];
                if(i==i++){
                    pos=[select id,PO_Startnumber__c,musqot__PO_Lastnumber__c ,musqot__PO_Prefix__c from musqot__Purchase_order_setting__c limit 250];
                    pos.musqot__PO_Lastnumber__c=a1 ;
                    
                    update pos;
                }
                
            }           
            //Attachment Code
            User u = [select Id from user where id=:userinfo.getuserid()];
            
            attachment.OwnerId = u.Id;
            attachment.ParentId = orders.Id; // the record the file is attached to
            //attachment.OwnerId = u.id;
            attachment.ContentType=contentType;
            if(attachment.body<>null){
                if (Schema.sObjectType.Attachment.fields.body.isCreateable()){
                
                    attachment.Name = orders.Purchase_order_name__c;
                    //attachment.Body=null;
                    insert attachment;                     
                }                  
            }
            sendEmail(orders,attachment);
           
            Pagereference PR;
            if(subprojectid<>null){  
                String tabId = System.currentPageReference().getParameters().get('tabId');
                string pageRef='/apex/SubProject?id='+EncodingUtil.urlEncode(subprojectid,'UTF-8')+'&tab='+EncodingUtil.urlEncode('purchase','UTF-8');
                pr=new Pagereference (pageRef);              
                // PR = new Pagereference('/apex/SubProject?id='+EncodingUtil.urlEncode(subprojectid,'UTF-8'));
            }
            else if(projectid<>null)
            {
                String tabId = System.currentPageReference().getParameters().get('tabId');
                string pageRef='/apex/ProjectDetails?id='+EncodingUtil.urlEncode(projectid,'UTF-8')+'&tab='+EncodingUtil.urlEncode('purchase','UTF-8');
                pr=new Pagereference (pageRef);
                //PR = new Pagereference('/apex/ProjectDetails?id='+EncodingUtil.urlEncode(projectid,'UTF-8'));
            }
            else if(markID<>null)
            {
                String tabId = System.currentPageReference().getParameters().get('tabId');
                string pageRef='/apex/Marketingactivity?id='+EncodingUtil.urlEncode(markID,'UTF-8')+'&tab='+EncodingUtil.urlEncode('purchase','UTF-8');
                pr=new Pagereference (pageRef);
                // PR = new Pagereference('/apex/Marketingactivity?id='+EncodingUtil.urlEncode(markID,'UTF-8'));
            }
            return PR;
        }
        catch(Exception e){
            return null;
        }
    }
   public Attachment attachment {
        get {
            if (attachment == null)
                attachment = new Attachment();
            return attachment;
        }
        set;
    }
    Public Pagereference cancel(){
        
        Pagereference PR;
           if(projectid<>null)
        {
            String tabId = System.currentPageReference().getParameters().get('tabId');
            string pageRef='/apex/ProjectDetails?id='+EncodingUtil.urlEncode(projectid,'UTF-8')+'&tab='+EncodingUtil.urlEncode('purchase','UTF-8');
            pr=new Pagereference (pageRef);
            // PR = new Pagereference('/apex/ProjectDetails?id='+EncodingUtil.urlEncode(projectid,'UTF-8'));
        }
        
      else  if(subprojectid<>null)
        {
            String tabId = System.currentPageReference().getParameters().get('tabId');
            string pageRef='/apex/SubProject?id='+EncodingUtil.urlEncode(subprojectid,'UTF-8')+'&tab='+EncodingUtil.urlEncode('purchase','UTF-8');
            pr=new Pagereference (pageRef);
            //PR = new Pagereference('/apex/SubProject?id='+EncodingUtil.urlEncode(subprojectid,'UTF-8'));
        }
       
        else if(markID<>null)
        {
            String tabId = System.currentPageReference().getParameters().get('tabId');
            string pageRef='/apex/Marketingactivity?id='+EncodingUtil.urlEncode(markID,'UTF-8')+'&tab='+EncodingUtil.urlEncode('purchase','UTF-8');
            pr=new Pagereference (pageRef);
            //PR = new Pagereference('/apex/Marketingactivity?id='+EncodingUtil.urlEncode(markID,'UTF-8'));
        }
        
        return PR;
    }       
    public String getRedirectToTemplate() {
        return null;
    }
    public Purchase_order__c  templateInfo {get; set;}
    public Pagereference redirectToTemplate() {
        try{
            insert templateInfo;
        }catch(Exception e){
            ApexPages.addMessages(e);
        }
        return null;
    }    
    public void sendEmail(Purchase_order__c orders,Attachment attachment){
        if(orders.Send_date__c ==System.today() && orders.musqot__Supplier_email__c != null && orders.musqot__Supplier_email__c != ''){ 
            Purchase_order__c  purchOrdr = [SELECT Id,musqot__Purchase_order_name__c,Name,musqot__Total_cost__c,musqot__Description__c, OwnerId FROM Purchase_order__c WHERE Id = :orders.Id];
            EmailTemplate template = [SELECT Id, name,Subject, HtmlValue, Body FROM EmailTemplate WHERE name= 'Purchaseorder'];
            //Contact cnt = [select id from Contact where email != null limit 1];
            Contact cnt = new Contact();
            cnt.LastName = 'Supplier';
            cnt.Email = orders.musqot__Supplier_email__c;
            insert cnt;
            Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
            mail.setWhatId(purchOrdr.Id);
            mail.setTargetObjectId(cnt.Id);
            mail.setTemplateId(template.Id);
            mail.saveAsActivity = false;
          
              if(attachment.body<>null){
                //Set email file attachments
                List<Messaging.Emailfileattachment> fileAttachments = new List<Messaging.Emailfileattachment>();
                // Add to attachment file list
                Messaging.Emailfileattachment efa = new Messaging.Emailfileattachment();
                efa.setFileName(attachment.Name);
                efa.setBody(attachment.Body);
                efa.setContentType(attachment.ContentType);
                fileAttachments.add(efa);
                mail.setFileAttachments(fileAttachments);
            }
            //Send email
            Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail }); 
            delete cnt;           
        }       
     }
 }



In the class i didn't use any where soql query's and DML statemets inside for loops, but still i'l get bulkify apex methods warning from this line...
public void sendEmail(Purchase_order__c orders,Attachment attachment){............
I have updated my controller, can u pls tell me from where i did wrong in my code??????
 

Hi developers,

                        how can we change the default Salesforce CRM UI.

defaultly some look and feel is observing in CRM but is possible to change as we customize some social networks themes. How can we? plz suggest options.