• Tushar sharma
  • NEWBIE
  • 115 Points
  • Member since 2014

  • Chatter
    Feed
  • 3
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 50
    Replies
apex trigger contactscreation caused an unexpected exception, contact your administrator: contactscreation: execution of AfterInsert caused by: System.DmlException: Insert failed. error: FIELD_CUSTOM_VALIDATION_EXCEPTION, only dollar and gup allow: [currency__c]: line 22, column 1

trigger contactscreation on Account (after insert) {
 map<id,decimal> m1=new map<id,decimal>();
 list<contact> l1=new list<contact>();
 
  for(account acc:trigger.new)
  {
  m1.put(acc.id,acc.Number_of_loc__c);
 }
 if(m1.size()>0 && m1!=null)
 {
  for(id accid:m1.keyset())
  {
  for(integer i=0;i<m1.get(accid);i++)
  {
   contact c1=new contact();
   c1.accountid=accid;
   c1.lastname='contact'+i;
   l1.add(c1);
   }
   }
     if(l1.size()>0&&l1!=null)
insert l1;
   }
 
   }
I've created a custom login page for my customer community login members. Here is my controller for the login page:
/**
 * An apex page controller that exposes the site login functionality
 */
global with sharing class CustomLoginController {
    global String username{get;set;}
    global String password{get;set;}
    global CustomLoginController () {}
    global PageReference forwardToCustomAuthPage() {
        return new PageReference( '/CostCenterLogin');
    }
    global PageReference login() {
        return Site.login(username, password, null);
    }

}

Here is the controller for my landing page:
public with sharing class topIdeaExt {
           
    public List<Idea> getRecent2()
    {
        return [SELECT Id, Title, Name__c, CreatedDate, Voting_Status__c FROM Idea order by createdDate desc Limit 2];
    }
    public List<Idea> getMostVoted2()
    {
        return [SELECT Id, Title, Name__c, CreatedDate, Voting_Status__c FROM Idea order by VoteTotal desc, CreatedDate desc Limit 2];
    }
    public List<AggregateResult> getTop6Contributors()
    {
        return [SELECT CreatedById, CreatedBy.Name Name  FROM Idea group by createdbyid, CreatedBy.Name order by count(CreatedById) desc limit 6];
    }
    
     // Code we will invoke on page load.
    public PageReference forwardToCustomAuthPage() {
        if(UserInfo.getUserType() == 'Guest'){
            return new PageReference('/CostCenterLogin');
        }
        else{
            return null;
        }
    }

    public topIdeaExt() {}
}

I've set up the login and landing pages in my communities setup and added customer community login user profile to my settings already. When I go to login as a test user, it seems to load, but it doesn't take me to the landing page.

Any ideas on how to fix this issue? I've been using this as a reference: 
http://appirio.com/category/tech-blog/2013/10/create-custom-salesforce-communities-login-landing-page/

Thanks!

Hi, 
    Can someone please help me. I've mentioned the job list below. In this I would like to get the Id of Scheduled Job name.

for example I have a scheduled job name "Accounts without Activities" in the list below, and I need  the Id of this scheduled job name.


User-added image
Thanks inadvance,
sam
I am keep getting this error
Challenge Not yet complete... here's what's wrong: 
The All Lusso Scarpe Employee group page must display the following information on the right side of the page: recommended groups and individuals to follow, and the most popular topics currently under discussion.
Close errors
User-added imageI have added exact steps but not sure why in trnding topic  I am seeing this error that topic is not enabled. I think this may be the issue but not sure how to fixed this. Is someone else also face this issue?
I am using Custom Action in SF1 for simple redirect purpose. They are working fine till tomorrow. But today, when i add Namespace to my org they suddenly stop working.

I add them in the page layout but still they are not visible in SF1 detail page. I checked and test this in another org and same thing happened there. first they are working but after namespace addition they stopped working(not visible in UI).

Is this a known bug or did i missed anything. If anybody have any workaround or any solution please let me know.
I am using Map<string, sObject> now i want to bind these value with radio button how can i do this.

I am using Wrapper class Map<string,Wrapper> concept but the problem is in this case checkbox is working but Radio button is not working
and in map values coming as
WrapperMapping:[sObje=Account:{Name=GenePoint, Phone=(650) 867-3450, AccountNumber=CC978213, Fax=(650) 867-9895, Id=0019000000ySnxzAAC}, selected=null, selectedR=false, status=null]
Now i want to access only ID column in VF how can i do this Please help

I am using merge field in if condition command link tag but it don't get any value.
<apex:repeat value="{!st}" var="lable">

<apex:commandLink action="{!getValue}" value="{!lable}  {!IF(sortField=='{!lable}',IF(sortDir=='ASC','↑','↓'),'')}" rerender="showRecord" status="actStatusId">



Here IF(sortField=='{!lable}' here {!lable} don't get any value how to do this
I want to write a Lightning Web Component that launches as a Quick Action from a button on a Lightning record page just like the Edit button does where a modal window opens and the record page is grayed out until the model window closed.  That component will make some changes to the record.

Question, when the component closes and the record page behind it is reactivated, will it be updated to reflect that latest data?
I have a lightning component embedded in a flow, how do I pass the recordId from the flow into the lightning component?

Everything I have found shows the old flow designer.  The new lightning flow designer does not have an option to set input fields on the lightning component.

Thanks.
Component:

<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction"
                access="global"
                controller="fileViewerCtrl">
    <!--aura doInit handler--> 
    <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
 
    
    <!--aura attributes-->  
    <aura:attribute name="selectedDocumentId" type="string"/>
    <aura:attribute name="lstContentDoc" type="List"/>
    <aura:attribute name="hasModalOpen" type="boolean" default="false"/>
    <header>
            <h2>Global Post Incident Reports</h2>
        </header>
    <!-- Custom DataTable to Display List Of Available ContentDocuments Start-->  
        <table class="slds-table slds-table_cell-buffer slds-table_bordered">
        <thead>
            <tr class="slds-line-height_reset">
                <th class="slds-text-title_caps" scope="col">
                    <div class="slds-truncate" title="Title" onclick="{!c.sortbyTitle}">Title</div>
                </th>
                <th class="slds-text-title_caps" scope="col">
                    <div class="slds-truncate" title="File Type" onclick="{!c.sortbyFileType}">File Type</div>
                </th>
                <th class="slds-text-title_caps" scope="col">
                    <div class="slds-truncate" title="size" onclick="{!c.sortbySize}">size(bytes)</div>
                </th>
                 <th class="slds-text-title_caps" scope="col">
                    <div class="slds-truncate" title="Last Modified Date" onclick="{!c.sortbyLastModifiedDate}">Last Modified Date</div>
                </th>
            </tr>
        </thead>
        <tbody>
            <aura:iteration items="{!v.lstContentDoc}" var="CD">
                <tr>
                    <th scope="row">
                        <div class="slds-truncate" title="{!CD.ContentDocument.Title}">
                            <!--store contentDocument Id in data-Id attribute-->
                            <a onclick="{!c.getSelected}" data-Id="{!CD.ContentDocument.Id}">{!CD.ContentDocument.Title}</a>
                        </div>
                    </th>
                    <th scope="row">
                        <div class="slds-truncate" title="{!CD.ContentDocument.FileType}">{!CD.ContentDocument.FileType}</div>
                    </th>
                    
                    <th scope="row">
                        <div class="slds-truncate" title="{!CD.ContentDocument.ContentSize}">{!CD.ContentDocument.ContentSize}</div>
                    </th>
                    <th scope="row">
                        <div class="slds-truncate" title="{!CD.ContentDocument.LastModifiedDate}">{!CD.ContentDocument.LastModifiedDate}</div>
                    </th>
                </tr>  
            </aura:iteration>
        </tbody>
    </table>
    <!-- Custom DataTable to Display List Of Available ContentDocuments End-->  
    <!--###### FILE PREVIEW MODAL BOX START ######--> 
    <aura:if isTrue="{!v.hasModalOpen}">
 <section onclick="{!c.closeModel}"
                 role="dialog"
                 aria-modal="true"
                 class="slds-modal slds-fade-in-open">
            <div class="slds-modal__container">
                <div class="slds-modal__content slds-p-around_medium slds-text-align_center"
                     style="background: transparent;">
                    <div style="width: 50%; margin: 0 auto; text-align: left">
                        <!--<lightning:fileCard> to preview file using content document Id -->
                        <lightning:fileCard fileId="{!v.selectedDocumentId}"/>
                    </div>
                </div>
            </div>
        </section>
        <div class="slds-backdrop slds-backdrop_open"></div>
    </aura:if>
    <!--###### FILE PREVIEW MODAL BOX END ######-->
    
</aura:component>

Controller:

({
    /*call apex controller method "fetchContentDocument" to get salesforce file records*/
    doInit : function(component, event, helper) {
        var action = component.get("c.fetchContentDocument");
         action.setParams({ clickedItem : 'PIR' });

        action.setCallback(this, function(response) {
            var state = response.getState();
            if (state === "SUCCESS") {
                component.set('v.lstContentDoc', response.getReturnValue());
            }
            else if (state === "INCOMPLETE") {
                // do something
            }
                else if (state === "ERROR") {
                    var errors = response.getError();
                    if (errors) {
                        if (errors[0] && errors[0].message) {
                            console.log("Error message: " + 
                                        errors[0].message);
                        }
                    } else {
                        console.log("Unknown error");
                    }
                }
        });
        $A.enqueueAction(action);  
    },
    getSelected : function(component,event,helper){
        // display model and set seletedDocumentId attribute with selected record Id   
        component.set("v.hasModalOpen" , true);
        component.set("v.selectedDocumentId" , event.currentTarget.getAttribute("data-Id")); 
        
    },
    closeModel: function(component, event, helper) {
        // for Close Model, set the "hasModalOpen" attribute to "FALSE"  
        component.set("v.hasModalOpen", false);
        component.set("v.selectedDocumentId" , null); 
    },
        sortByTitle: function(component, event, helper) {
        helper.sortBy(component, "Title");
    },
    sortByFileType: function(component, event, helper) {
        helper.sortBy(component, "FileType");
    },
        sortBySize: function(component, event, helper) {
        helper.sortBy(component, "Size");
    },
    sortByLastModifiedDate: function(component, event, helper) {
        helper.sortBy(component, "LastModifiedDate");
    }
    
})

Helper: 

({
    sortBy: function(component, field) {
        var sortAsc = component.get("v.sortAsc"),
            sortField = component.get("v.sortField"),
            records = component.get("v.lstContentDoc"),
            fieldPath = field.split(/\./),
            fieldValue = this.fieldValue;
        sortAsc = sortField != field || !sortAsc;
        records.sort(function(a,b){
            var aValue = fieldValue(a, fieldPath),
                bValue = fieldValue(b, fieldPath),
                t1 = aValue == bValue,
                t2 = (!aValue && bValue) || (aValue < bValue);
            return t1? 0: (sortAsc?-1:1)*(t2?1:-1);
        });
        component.set("v.sortAsc", sortAsc);
        component.set("v.sortField", field);
        component.set("v.lstContentDoc", records);
        this.renderPage(component);     
    },
    fieldValue: function(object, fieldPath) {
        var result = object;
        fieldPath.forEach(function(field) {
            if(result) {
                result = result[field];
            }
        });
        return result;
    },
    renderPage: function(component) {
        var records = component.get("v.lstContentDoc"),
            pageNumber = component.get("v.pageNumber"),
            pageRecords = records.slice((pageNumber-1)*10, pageNumber*10);
        component.set("v.currentList", pageRecords);
    }
})

fileViewerCtrl Apex Class:

public class fileViewerCtrl {
    @AuraEnabled 
    public static List<ContentWorkspaceDoc> fetchContentDocument(string clickedItem){
        if(clickedItem == 'PIR'){
            
            ContentWorkspace cw = [SELECT Id, RootContentFolderId FROM ContentWorkspace WHERE Name ='Global Post Incident Reports' LIMIT 1];
            
            return [SELECT Id , ContentDocumentId, ContentDocument.title,ContentDocument.FileType, ContentDocument.CreatedBy.Name, ContentDocument.ContentSize, ContentDocument.LastModifiedDate from ContentWorkspaceDoc where ContentWorkspaceId =: cw.Id LIMIT 1000];
            
        }
        else if(clickedItem == 'Release'){
            
             ContentWorkspace cw = [SELECT Id, RootContentFolderId FROM ContentWorkspace WHERE Name ='Release Deployment Plan' LIMIT 1];
            
            return [SELECT Id , ContentDocumentId, ContentDocument.title,ContentDocument.FileType, ContentDocument.CreatedBy.Name, ContentDocument.ContentSize, ContentDocument.LastModifiedDate from ContentWorkspaceDoc where ContentWorkspaceId =: cw.Id LIMIT 1000];              
        }
      else{
            
             ContentWorkspace cw = [SELECT Id, RootContentFolderId FROM ContentWorkspace WHERE Name ='PDR' LIMIT 1];
            
            return [SELECT Id , ContentDocumentId, ContentDocument.title,ContentDocument.FileType, ContentDocument.CreatedBy.Name, ContentDocument.ContentSize, ContentDocument.LastModifiedDate from ContentWorkspaceDoc where ContentWorkspaceId =: cw.Id LIMIT 1000];              
        }             
    }
}
I've created a custom Lookup field to look into Accounts and have the ability to multi-select accounts. I want to place this field on the Opportunity Object as we have an Account Record Type for Partners. I want to be able to select multiple partners that will work on an opportunity. 
The lookup works but I am not able to display checkboxes for a multiselect function. Can anyone help?

Apex Class
CustomAccountLookupController
public with sharing class CustomAccountLookupController {
  
  public Account account {get;set;} // new account to create
  public List<Account> results{get;set;} // search results
  public string searchString{get;set;} // search keyword
  
  public CustomAccountLookupController() {
    account = new Account();
    // get the current search string
    searchString = System.currentPageReference().getParameters().get('lksrch');
    runSearch();  
  }
   
  // performs the keyword search
  public PageReference search() {
    runSearch();
    return null;
  }
  
  // prepare the query and issue the search command
  private void runSearch() {
    // TODO prepare query string for complex serarches & prevent injections
    results = performSearch(searchString);               
  } 
  
  // run the search and return the records found. 
  private List<Account> performSearch(string searchString) {

    String soql = 'select id, name from account';
    if(searchString != '' && searchString != null)
      soql = soql +  ' where name LIKE \'%' + searchString +'%\'';
    soql = soql + ' limit 25';
    System.debug(soql);
    return database.query(soql); 

  }
  
  // save the new account record
  public PageReference saveAccount() {
    insert account;
    // reset the account
    account = new Account();
    return null;
  }
  
  // used by the visualforce page to send the link to the right dom element
  public string getFormTag() {
    return System.currentPageReference().getParameters().get('frm');
  }
    
  // used by the visualforce page to send the link to the right dom element for the text box
  public string getTextBox() {
    return System.currentPageReference().getParameters().get('txt');
  }
 
}


Apex Class
MyCustomLookupController
public with sharing class MyCustomLookupController {
   
  public Contact contact {get;set;}
  
  public MyCustomLookupController() {
    contact = new Contact();
  }
    
}

Visualforce Page
CustomAccountLookup
<apex:page controller="CustomAccountLookupController"
  title="Search" 
  showHeader="false" 
  sideBar="false" 
  tabStyle="Account" 
  id="pg">
  
  <apex:form >
  <apex:outputPanel id="page" layout="block" style="margin:5px;padding:10px;padding-top:2px;">
    <apex:tabPanel switchType="client" selectedTab="name1" id="tabbedPanel">
    
      <!-- SEARCH TAB -->
      <apex:tab label="Search" name="tab1" id="tabOne">
          
        <apex:actionRegion >  
          <apex:outputPanel id="top" layout="block" style="margin:5px;padding:10px;padding-top:2px;">
            <apex:outputLabel value="Search" style="font-weight:Bold;padding-right:10px;" for="txtSearch"/>
            <apex:inputText id="txtSearch" value="{!searchString}" />
              <span style="padding-left:5px"><apex:commandButton id="btnGo" value="Go" action="{!Search}" rerender="searchResults"></apex:commandButton></span>
          </apex:outputPanel>
     
          <apex:outputPanel id="pnlSearchResults" style="margin:10px;height:350px;overflow-Y:auto;" layout="block">
            <apex:pageBlock id="searchResults"> 
              <apex:pageBlockTable value="{!results}" var="a" id="tblResults">
                <apex:column >
                  <apex:facet name="header">
                    <apex:outputPanel >Name</apex:outputPanel>
                  </apex:facet>
                   <apex:outputLink value="javascript:top.window.opener.lookupPick2('{!FormTag}','{!TextBox}_lkid','{!TextBox}','{!a.Id}','{!a.Name}', false)" rendered="{!NOT(ISNULL(a.Id))}">{!a.Name}</apex:outputLink>     
                </apex:column>
              </apex:pageBlockTable>
            </apex:pageBlock>
          </apex:outputPanel>
        </apex:actionRegion>
          
      </apex:tab>
      
      <!-- NEW ACCOUNT TAB -->
      <apex:tab label="New Account" name="tab2" id="tabTwo">

        <apex:pageBlock id="newAccount" title="New Account" >
        
          <apex:pageBlockButtons >
            <apex:commandButton action="{!saveAccount}" value="Save"/>
          </apex:pageBlockButtons>
          <apex:pageMessages />
        
          <apex:pageBlockSection columns="2">
            <apex:repeat value="{!$ObjectType.Account.FieldSets.CustomAccountLookup}" var="f">
              <apex:inputField value="{!Account[f]}"/>
            </apex:repeat>
          </apex:pageBlockSection> 
        </apex:pageBlock>
          
      </apex:tab>
    </apex:tabPanel>
  </apex:outputPanel>
  </apex:form>
</apex:page>

Visualforce Page
MyCustomLookup
<apex:page controller="MyCustomLookupController" id="Page" tabstyle="Contact">

  <script type="text/javascript"> 
  function openLookup(baseURL, width, modified, searchParam){
    var originalbaseURL = baseURL;
    var originalwidth = width;
    var originalmodified = modified;
    var originalsearchParam = searchParam;
    
    var lookupType = baseURL.substr(baseURL.length-3, 3);
    if (modified == '1') baseURL = baseURL + searchParam;
    
    var isCustomLookup = false;
    
    // Following "001" is the lookup type for Account object so change this as per your standard or custom object
    if(lookupType == "001"){
  
      var urlArr = baseURL.split("&");
      var txtId = '';
      if(urlArr.length > 2) {
        urlArr = urlArr[1].split('=');
        txtId = urlArr[1];
      }
      
      // Following is the url of Custom Lookup page. You need to change that accordingly
      baseURL = "/apex/CustomAccountLookup?txt=" + txtId;
      
      // Following is the id of apex:form control "myForm". You need to change that accordingly
      baseURL = baseURL + "&frm=" + escapeUTF("{!$Component.myForm}");
      if (modified == '1') {
        baseURL = baseURL + "&lksearch=" + searchParam;
      }
      
      // Following is the ID of inputField that is the lookup to be customized as custom lookup
      if(txtId.indexOf('Account') > -1 ){
        isCustomLookup = true;
      }
    }
 
    
    if(isCustomLookup == true){
      openPopup(baseURL, "lookup", 350, 480, "width="+width+",height=480,toolbar=no,status=no,directories=no,menubar=no,resizable=yes,scrollable=no", true);
    }
    else {
      if (modified == '1') originalbaseURL = originalbaseURL + originalsearchParam;
      openPopup(originalbaseURL, "lookup", 350, 480, "width="+originalwidth+",height=480,toolbar=no,status=no,directories=no,menubar=no,resizable=yes,scrollable=no", true);
    } 
  }
</script>

<apex:sectionHeader title="Demo"  subtitle="Custom Lookup" />

  <apex:form id="myForm">  
    <apex:PageBlock id="PageBlock">     
      <apex:pageBlockSection columns="1" title="Custom Lookup">
        <apex:inputField id="Account" value="{!contact.AccountId}"  />
      </apex:pageBlockSection>
    </apex:PageBlock>
  </apex:form>
       
</apex:page>

 
  • November 14, 2018
  • Like
  • 0
Hi, i would like to know if i can use the google drive api through rest api integration using only a lightning component without a VF page.

I watched this video: https://www.youtube.com/watch?v=rPgH5bnIn7Y abd this https://www.youtube.com/watch?v=0gRS8JWKIFI abd both use a VF page for the redirect uri authorized in google api. But would i need to use the VF page or how can i put the redirect to be a record page (Accounts) because the URL change depending on the account record.

Thanks in advance, i will appreciate any help :)
Hi,
     How to create multiple records selection from lookup field in salesforce which supports in lightning.
Thanks.
 
apex trigger contactscreation caused an unexpected exception, contact your administrator: contactscreation: execution of AfterInsert caused by: System.DmlException: Insert failed. error: FIELD_CUSTOM_VALIDATION_EXCEPTION, only dollar and gup allow: [currency__c]: line 22, column 1

trigger contactscreation on Account (after insert) {
 map<id,decimal> m1=new map<id,decimal>();
 list<contact> l1=new list<contact>();
 
  for(account acc:trigger.new)
  {
  m1.put(acc.id,acc.Number_of_loc__c);
 }
 if(m1.size()>0 && m1!=null)
 {
  for(id accid:m1.keyset())
  {
  for(integer i=0;i<m1.get(accid);i++)
  {
   contact c1=new contact();
   c1.accountid=accid;
   c1.lastname='contact'+i;
   l1.add(c1);
   }
   }
     if(l1.size()>0&&l1!=null)
insert l1;
   }
 
   }
Hi,

I am having a approval process which is having 4 stages of approver

i want to capture the comments enterd by the 3 level of approver alone (not any other apperover) in a custom  field 

Help me how to achieve it

Thanks in Advance
Hello - I have a long multipicklist with many departments ending in (*) - e.g. 'Assessor (*) and am trying to create a validation rule to return an error for departments ending in (*).  However, INCLUDES does not recognize less than the full value.  Is there a solution that does not involve listing each department?  Thanks!

AND(
 INCLUDES(Dept_Division_Compliment_Complaint__c, '(*)'),
  ISBLANK(Email_Date_Time_manual_fwd_cases_only__c),
   Text(Status) = "Closed")
 
i was facing problem with the test class for the following trigger.

trigger opportunityinsertupdate on opportunity(before insert,before update) {
boolean flag=True;
    if(trigger.isInsert) {
         for(opportunity o :[Select Id, Name, Record_Type_Name__c, FS_Included__c, account.Super_Region__c, Check__c, 
                            stagename, amount, CurrencyIsoCode, Target_ShipDate__c
                            From Opportunity Where Id IN :trigger.new]) {
            if(((o.Record_Type_Name__c == 'NC Power')||(o.Record_Type_Name__c == 'NC Oil & Gas')) && (o.FS_Included__c == false) && (o.account.Super_Region__c == 'Asia/India')) {
                o.stagename = 'Sales Lead';
                o.amount = 1;
                o.CurrencyIsoCode = 'USD';
                o.Target_ShipDate__c = o.Target_ShipDate__c.addmonths(3);
                flag = false;
            }
        }
    }
   
    if(trigger.isUpdate && flag)  {
        for(opportunity o1 :[Select Id, Name, Record_Type_Name__c, FS_Included__c, account.Super_Region__c, Check__c, 
                            stagename, amount, CurrencyIsoCode, Target_ShipDate__c
                            From Opportunity Where Id IN :trigger.new]){
            if(((o1.Record_Type_Name__c == 'NC Power')||(o1.Record_Type_Name__c == 'NC Oil & Gas')) && (o1.FS_Included__c == false) && o1.account.Super_Region__c == 'Asia/India' && o1.Check__c == false) {
                o1.stagename = 'Sales Lead';
                o1.amount = 1;
                o1.CurrencyIsoCode = 'USD';
                o1.Target_ShipDate__c = o1.Target_ShipDate__c.addmonths(3);
                o1.Check__c = true;
            }
       
        }
    }
}

can any one tell how to caver this trigger
Hello!

Is there any way to check salesforce remaining mass email limit in advance? i.e. count of emails that I can further send through mass email today?

Or I'll got to know about this only when there is an exception while sending mass emails from salesforce? - MASS_EMAIL_LIMIT_EXCEEDED

Thanks in advance

Hi ,
I want to delete record by using row index . Instead of wrapper class instance by using instance  List<object> i can do this.But with warpper class how can i get the recrords and remove the record.

It showing error
Method does not exist or incorrect signature: [LIST<addAttendee.turbinewrapper>].get(SOBJECT:Turbines__c)

Can any one suggest plaese ......

public turbinewrapper del;
public List<Turbines__c> delturbineList {get;set;}
public void deleteRow(){

rowIndex = Integer.valueOf(ApexPages.currentPage().getParameters().get('rowIndex'));
System.debug('rowbe deleted @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@' + rowIndex );
System.debug('rowm to be deleted '+turbineList[rowIndex]);
Turbines__c tur = new Turbines__c();
  del= turbineList.get(tur).remove(rowIndex);
delturbineList .add(del);


Regards,
sarvesh.
Hi,

I am actually trying to deploy few custom fields from sandbox to production using an existing deployment connection.
But when I deploy i am getting the following error message.
"Your organization's code coverage is 0%. You need at least 75% coverage to complete this deployment. Also, the following triggers have 0% code coverage. Each trigger must have at least 1% code coverage."

What is the reason for this?
should we rewrite/update the test class for the existing triggers?
I have a trigger that I can't get code coverage on an if statment. What am i doing wrong. 
I can't get code coverage on line 33 "if (a.AccountTeamMembers == Null || a.AccountTeamMembers.isEmpty()

Here's the trigger:
trigger trgAsset on Asset (after insert, after update, after delete) {
	if (trigger.isInsert || trigger.isUpdate){
		/*If the Asset has VersaDoc and the account doesn't have a VersaDoc Project Account Team Member, 
		  it will assign the next VersaDoc Project manager from the assignment groups to the Account Team*/

        Set<id> accountTeamAccountIds = new Set<id>(); // set of accountIDs that have VersaDoc in the asset
	    for (Asset a : Trigger.new){  
	    	if (a.HasVersadoc__c == 1 || a.HasVersadocStudio__c == 1 ) {
        		accountTeamAccountIds.add(a.AccountId); 
       	 	} 	
	    }
        
		list<Assignment_Group_Name__c> asgnGroupNameIDs = [SELECT Id FROM Assignment_Group_Name__c WHERE Name = 'Support - VersaDoc Project Managers' limit 1];
		system.debug('asgnGroupnameIDs is ' + asgnGroupNameIDs);
	
		Assignment_Groups__c[] asgnGroups = new List<Assignment_Groups__c>([SELECT Group_Name__c, User__c, Last_Assignment__c, Millisecond__c 
                                   FROM Assignment_Groups__c 
                                   WHERE Group_Name__c in :asgnGroupNameIds
                                   AND Active__c = 'True' AND User_Active__c = 'True'
                                   ORDER BY Last_Assignment__c, Millisecond__c] );                                    
	
		Integer groupCount = asgnGroups.size();
	
    	System.debug('>>>>>asgnGroups: '+asgnGroups);   
   		if (asgnGroups.isEmpty()) return;                      

		//loop through list of accounts and get the accounts w/o VersaDoc Project Manager
		AccountTeamMember[] NewMembers = new AccountTeamMember[]{};  //list of new team members to add
	    AccountShare[] newShare = new AccountShare[]{};  //list of new shares to add
		Map<id, Account> acctsToUpdate = new Map<id, Account>([Select a.Id, (Select Id, AccountId From AccountTeamMembers WHERE TeamMemberRole = 'VersaDoc Project Manager' limit 1) From Account a Where a.Id in :accountTeamAccountIds]);
		Integer cnt = 0;
	    for (Account a : acctsToUpdate.values()){
	    	if (a.AccountTeamMembers == null || a.AccountTeamMembers.isEmpty()) {
	    		AccountTeamMember TeamMemberAd=new AccountTeamMember();
		        TeamMemberAd.AccountId=a.id;
		        TeamMemberAd.UserId=asgnGroups[cnt].User__c;
		       	TeamMemberAd.TeamMemberRole = 'VersaDoc Project Manager';
		        NewMembers.add(TeamMemberAd);	
		        datetime now = datetime.now();
		        asgnGroups.get(cnt).Last_Assignment__c=now;
		        asgnGroups.get(cnt).Millisecond__c = now.millisecondGMT(); 
	    		cnt ++;
	    		if (cnt == groupCount){ cnt = 0;}    	
	    	}
	    } 

		//insert any valid members then add their share entry if they were successfully added
	    Database.SaveResult[] lsr = Database.insert(NewMembers,false);
		Integer newcnt=0;
	    for(Database.SaveResult sr:lsr){
			if(!sr.isSuccess()){
				Database.Error emsg = sr.getErrors()[0];
				system.debug('\n\nERROR ADDING TEAM MEMBER:'+emsg);
			}else{
				newShare.add(new AccountShare(UserOrGroupId=NewMembers[newcnt].UserId, AccountId=NewMembers[newcnt].Accountid, AccountAccessLevel='Edit',OpportunityAccessLevel='Edit'));
			}
				newcnt++;			
	    }
	    //insert the new shares
	    Database.SaveResult[] lsr0 =Database.insert(newShare,false); 
	    Integer newcnt0=0;
	    for(Database.SaveResult sr0:lsr0){
			if(!sr0.isSuccess()){
				Database.Error emsg0=sr0.getErrors()[0];
			    system.debug('\n\nERROR ADDING SHARING:'+newShare[newcnt0]+'::'+emsg0);
			}
				newcnt0++;
	    } 
	    // update assignment groups with their LastAssignmentDate
	    update asgnGroups; 	  
    }
}
Heres' the test class
@isTest(SeeAllData=false)
private class testTrgAssetVersaDocTeamAssignment {
    static testMethod void myUnitTest() {
        // create user to run the test a
        User u =  TestDataFactory.createTestRunAsUser('Standard User', 'Sales Assistant');  
        
        System.runAs(u) {  
            // Switch to the runtime 
             Test.StartTest();
            	// TestDataFactory.createProduct('PrinterPresence Gold Level', 'VersaDoc');
                list<Account> printAccts = TestDataFactory.createTestAccounts(2, 'Printers', 'Client');
                system.debug('***** printAccts is ' + printAccts);
                performCreateAssignmentGroups(u.Id);   
                checkVersaDocAccountTeam(printAccts);
                performCreateVersaDocAssets(u.Id, printAccts);  
            Test.StopTest();   
         }
    }
    
    public static void performCreateAssignmentGroups(id createdby){
        Assignment_Group_Name__c agn = TestDataFactory.createAssignmentGroup('Support - VersaDoc Project Managers', 'Account');
        list<User> u = TestDataFactory.createMulitpleUsers(2, 'Standard User-Support VersaDoc', 'Product Support Rep');     
        system.debug('**** user list is' + u);
        TestDataFactory.addUsersToAssigmentGroup(u, agn);
    }   
    
    public static void checkVersaDocAccountTeam(list <Account> accts){
        Map<id, Account> acctsToCheck = new Map<id, Account>([Select a.Id, (Select Id, AccountId From AccountTeamMembers WHERE TeamMemberRole = 'VersaDoc Project Manager' limit 1) From Account a Where a.Id in :accts]);
        List<Id> acct = new list<Id>();
        System.debug('**** acctsToCheck is ' + acctsToCheck);
        for (Account a: acctsToCheck.values()){
            if (a.AccountTeamMembers == null || a.AccountTeamMembers.isEmpty()) {
				system.debug('**** in if statement if for loop ' + acctsToCheck.values());
                acct.add(a.Id);
        	}
        }
        system.assert(acct.size()>0);
    }
    
    public static void performCreateVersaDocAssets(id createdby, List <Account> accts){
        // add PrinterPresence Gold level Asset (Has VersaDoc)
        date now = date.today(); 
        list<Account> acct = [Select Id from Account where id =: accts];
        list<Asset> assts = new list<Asset>();        
        assts = TestDataFactory.createAssets(accts, now, 'PrinterPresence Gold Level', 'Purchased', 310.00, 7500.00);
        system.debug('***** assts is ' + assts);
        
        Map<id, Account> acctTeams = new map<id, Account>([Select a.Id, (Select Id, AccountId, TeamMemberRole From AccountTeamMembers WHERE TeamMemberRole = 'VersaDoc Project Manager' limit 1) From Account a Where a.Id  =:accts]);
        system.debug('**** acctTeams after adding assets is ' + acctTeams);
        for (Account a : acctTeams.values()){
        	if (a.AccountTeamMembers != null && a.AccountTeamMembers.IsEmpty()==false) {   
            System.assertNotEquals(a.AccountTeamMembers, Null);
            }
        } 
        System.assert(acct.size()>0);
    }
}


The overall code coverage is not being cleared, I have a trigger with no lines of code in it and it still shows as if it had 24 and only 58% of it covered.

How can I force salesforce to retest that trigger so it no longer shows like that since I think is affecting a new class I need to deploy, the new class has a code coverage of 82% but when I try to deploy it I get an error that my code coverage is 71%  
Hi,

We are working on cleaning up of Account Billing Address.
How can we approach this project?


Thanks!

I've created a custom login page for my customer community login members. Here is my controller for the login page:
/**
 * An apex page controller that exposes the site login functionality
 */
global with sharing class CustomLoginController {
    global String username{get;set;}
    global String password{get;set;}
    global CustomLoginController () {}
    global PageReference forwardToCustomAuthPage() {
        return new PageReference( '/CostCenterLogin');
    }
    global PageReference login() {
        return Site.login(username, password, null);
    }

}

Here is the controller for my landing page:
public with sharing class topIdeaExt {
           
    public List<Idea> getRecent2()
    {
        return [SELECT Id, Title, Name__c, CreatedDate, Voting_Status__c FROM Idea order by createdDate desc Limit 2];
    }
    public List<Idea> getMostVoted2()
    {
        return [SELECT Id, Title, Name__c, CreatedDate, Voting_Status__c FROM Idea order by VoteTotal desc, CreatedDate desc Limit 2];
    }
    public List<AggregateResult> getTop6Contributors()
    {
        return [SELECT CreatedById, CreatedBy.Name Name  FROM Idea group by createdbyid, CreatedBy.Name order by count(CreatedById) desc limit 6];
    }
    
     // Code we will invoke on page load.
    public PageReference forwardToCustomAuthPage() {
        if(UserInfo.getUserType() == 'Guest'){
            return new PageReference('/CostCenterLogin');
        }
        else{
            return null;
        }
    }

    public topIdeaExt() {}
}

I've set up the login and landing pages in my communities setup and added customer community login user profile to my settings already. When I go to login as a test user, it seems to load, but it doesn't take me to the landing page.

Any ideas on how to fix this issue? I've been using this as a reference: 
http://appirio.com/category/tech-blog/2013/10/create-custom-salesforce-communities-login-landing-page/

Thanks!
I have a custom object Deal_Reg__c. The business flow for this object is that a user can go to this object's page and add a Product to this Deal Reg. I have created a junction object called Deal_Reg_Products__c that has a Deg Reg Lookup as well as a Product Lookup along with other custom fields. After you press the "Add" button on the Deal Reg Products Related List section of the Deal Reg page, i would like the first VF page to be displayed.

The first VF page should basically only be a selectable list of all the Products. After the user selects one or multiple records to add to the specific Deal Reg, they will press a button called "Add Product". Pressing that button should fire off the second VF page.

The second VF page should consist of the selected list of Products from the first VF page along with a Deal_Reg_Products__c custom field, "Amount", next to each record where the user can input the value. After a value has been entered for each Product, the user will press a "Confirm" button which will send us back to the Deal Reg page where in the Deal Reg Products Related List section the selected Products are now visible and tied to that Deal Reg.

1. How to I tie this to the specific Deal Reg that the user would like to add the Products to?
2. After selecting the Products, how do I bring those values over to the second VF page where i can then enter in an "Amount" for each?
3. How can I get the "Confirm" button to actually commit the Products to the Deal Reg?

Here is the code i currently have:

VF Page 1:

<apex:page standardController="Deal_Registration_Products__c" extensions="wrapperClassController" tabstyle="Deal_Reg__c" id="myPage" recordSetVar="dealregproducts">
    <apex:form id="myForm">
        <apex:pageBlock title="Find Products" id="mypageBlock">
            <table width="100%">
                <tr>
                    <td width="25%" align="right">
                        <apex:pageBlockSection columns="1">
                            <b>By Keyword </b><br/>
                            <apex:inputText value="{!inputText1}" html-placeholder="Product Name"/>
                            <apex:commandButton value="Search" action="{!searchProduct}"/>  
                        </apex:pageBlockSection>
                    </td>
                </tr>
            </table>
            <br/>
            <p/>
        </apex:pageBlock>
        <apex:pageBlock >
            <apex:pageBlockButtons >
                <apex:commandButton value="Add Products" action="{!DisplayDetails}" rerender="table"/>
            </apex:pageBlockButtons>
            <!-- In our table we are displaying the cProduct records -->
            <apex:pageBlockTable value="{!products}" var="p" id="table">
                <apex:column >
                    <!-- This is our selected Boolean property in our wrapper class -->
                    <apex:inputCheckbox value="{!p.selected}"/>
                </apex:column>
                <!-- This is how we access the contact values within our cProduct container/wrapper -->
                <apex:column value="{!p.prod.Name}" />
                <apex:column value="{!p.prod.ProductCode}" />
                <apex:column value="{!p.prod.Description}" />
                <apex:column value="{!p.prod.Family}" />
            </apex:pageBlockTable>
            <apex:outputLabel >{!SelectedProd}</apex:outputLabel>
        </apex:pageBlock>
    </apex:form>
</apex:page>


VF Page 2:

<apex:page standardController="Deal_Registration_Products__c" extensions="wrapperClassController">
   <apex:form >
       <apex:pageBlock title="Deal Registration Products">
            <apex:pageBlockButtons >
                <apex:commandButton value="Confirm"/>
            </apex:pageBlockButtons>
            <apex:pageBlockTable value="{!SelectProdDetails}" var="p">
                <apex:column value="{!p.prod.Name}"/>
                <!-- <apex:column value="{!p.prod.Forecast_Amount__c}"/> -->
            </apex:pageBlockTable>
            <apex:outputPanel >
                <apex:outputLabel >{!SelectProdDetails}</apex:outputLabel>
            </apex:outputPanel>
        </apex:pageBlock>
    </apex:form>   
</apex:page>


Controller (I apologize for the mess here since I've been trying many different things):

public with sharing class wrapperClassController {

    public wrapperClassController(ApexPages.StandardSetController controller) {

    }


    public ApexPages.StandardSetController setCon {
        get {
            if(setCon == null) {
           
                    setCon = new ApexPages.StandardSetController(Database.getQueryLocator([Select Id,Name,ProductCode,Description,Family from Product2 Order by Name]));
            }
            system.debug('setConSize-----'+setCon.getResultSize());
            return setCon;
        }
        set;
    }
    
    public wrapperClassController(ApexPages.StandardController controller) {

    }

   
    public String inputText1 {get;set;}
    public String productName {get;set;}
    public Boolean isListEmpty {get;set;}
    public List<cProduct2> productWrapperlist = new List<cProduct2>();
    public List<List<cProduct2>> listOfProductWrapperlist = new List<List<cProduct2>>();
   
    //Our collection of the class/wrapper objects cProduct2
    public List<cProduct2> productList {get; set;}
    public List<cProduct2> selectedproductList {get; set;}
    public List<Product2> selectedProducts {get; set;}
    public List<Product2> selectedProd = new List<Product2>();

    //This method uses a simple SOQL query to return a List of Products
    public List<cProduct2> getProducts() {
        if(productList == null) {
            productList = new List<cProduct2>();
            for(Product2 p: [select Id, Name, ProductCode, Description, Family from Product2 limit 100]) {
                // As each product is processed we create a new cProduct2 object and add it to the productList
                productList.add(new cProduct2(p));
            }
        }
        return productList;
    }


    public void processSelected() {

        //We create a new list of Products that we be populated only with Products if they are selected
        //List<Product2>
        selectedProducts = new List<Product2>();

        //We will cycle through our list of cProducts and will check to see if the selected property is set to true, if it is we add the Product to the selectedProducts list
        for(cProduct2 cProd: getProducts()) {
            if(cProd.selected == true) {
                selectedProducts.add(cProd.prod);
            }
        }

        // Now we have our list of selected products and can perform any type of logic we want, sending emails, updating a field on the Product, etc
        //System.debug('These are the selected Products...');
       // for(Product2 prod: selectedProducts) {
       //     system.debug(prod);
       // }
       // productList=null; // we need this line if we performed a write operation  because getProducts gets a fresh list now
       // return null;
    }


    public List<cProduct2> getdealregProductsDetails()
    {
        //If there are records to be displayed then show the records else display message
        if((setCon.getResultSize()) > 0)
        {
            if(listOfProductWrapperlist[setCon.getPageNumber()-1].size() == 0) {
                productWrapperlist = new List<cProduct2>();
                for(Product2 p : (List<Product2>)setCon.getRecords()) {
                    productWrapperlist.add(new cProduct2(p));
                }
                listOfProductWrapperlist[setCon.getPageNumber()-1] = productWrapperlist;
            }
            system.debug('productWrapperlist-----'+productWrapperlist);
            return listOfProductWrapperlist[setCon.getPageNumber()-1];
        }
        else
        {
            return null;
        }          
    }
    // This is our wrapper/container class. A container class is a class, a data structure, or an abstract data type whose instances are collections of other objects. In this example a wrapper class contains both the standard salesforce object Contact and a Boolean value
    public class cProduct2 {
        public Product2 prod {get; set;}
        public Boolean selected {get; set;}

        //This is the contructor method. When we create a new cProduct2 object we pass a Product that is set to the con property. We also set the selected value to false
        public cProduct2(Product2 p) {
            prod = p;
            selected = false;
        }
       
        public cProduct2(Product2 prd, boolean check) {
            prod = prd;
            selected = check;
        }
    }
   
   
    public void searchProduct() {
            system.debug('productName : '+productName);
            if(productName != null && productName != '') {
                setCon = new ApexPages.StandardSetController(Database.query('Select Id,Name,ProductCode,Description,Family from Product2 where Name like \'%'+productName+'%\' Order by Name limit 2000'));
               
            } else {
                setCon = new ApexPages.StandardSetController(Database.getQueryLocator([Select Id,Name,ProductCode,Description,Family from Product2 Order by Name]));
            }
            listOfProductWrapperlist.clear();
            setCon.setPageSize(25);
            Integer reminder = math.mod(setCon.getResultSize(),setCon.getPageSize());
            Integer listToCreateSize = (reminder == 0?(setCon.getResultSize()/setCon.getPageSize()):(setCon.getResultSize()/setCon.getPageSize())+1);
            for(Integer i=0; i < listToCreateSize ; i++){
                listOfProductWrapperlist.add(new List<cProduct2>());
            }
            if(listOfProductWrapperlist== null || listOfProductWrapperlist.isEmpty()) {
                isListEmpty = true;
            }      
        }
       
    public PageReference getForecastAmount() {
        Page.DealRegProducts.getParameters().put('products_selected', 'selectedProducts');
        //processSelected();
        return Page.DealRegProducts;
    }
   
    //public PageReference secondTry() {
    //    PageReference page = Page.DealRegProducts;
    //    page.getParameters().put(Id, selectedProducts.Id);
    //    return page;
    //}
   
    public List<Product2> getSelectedProd() {
        if(selectedProd.size()>0) {
            System.debug(' selectProd '+selectedProd);
            return selectedProd;
        }
        else
        return null;
    }
   
    public PageReference DisplayDetails() {
        selectedproductList = new List<cProduct2>();
       
        for(cProduct2 prd : productList) {
            if(prd.selected == true) {
                selectedproductList.add(prd);
            }
        }
       
        PageReference reRend = new PageReference('/apex/DealRegProducts');
        reRend.setRedirect(false);
        return reRend;
    }
   
    public List<cProduct2> getProdDetails() {
        productList = new List<cProduct2>();
        List<Product2> prods = [Select Id,Name,ProductCode,Description,Family from Product2 Order by Name];
       
        for(Product2 p : prods) {
            productList.add(new cProduct2(p, false));
        }
        return productList;
    }
   
    public List<cProduct2> getSelectProdDetails() {
        selectedproductList = new List<cProduct2>();
       
        for(cProduct2 c : getProdDetails()) {
            System.debug(' selectProdDetails ' + c);
           
            if(c.selected == true)
            selectedproductList.add(c);
        }
        return selectedproductList;
    }
}