• Vanitha Mani
  • NEWBIE
  • 10 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 66
    Questions
  • 18
    Replies
 User-added imageif the value of product chnages inside form but still combobox is not refreshing to new values and i need to submit the value to case object..i need to save the selected value in combobox to failure point lookup field in case..

<lightning:recordEditForm recordId ="{!v.recordId}" objectApiName = "Case" aura:id="leadCreateForm1" onload="{!c.Onload}" onsubmit="{!c.handleSubmitForm}" >
        <lightning:messages />
<lightning:inputField aura:id="newOpportunityField" fieldName="Solution__c" required ="true"/>
             <lightning:layout horizontalAlign="left">
           <lightning:layoutItem size="12">
             <lightning:inputField aura:id="newOpportunityField" fieldName="Product_Build__c" required ="true" onchange="{!c.productchanged}" />
            <a href="javascript:void(0)"  iconPosition ="right" onclick="{!c.changeprod}">Change</a>
               <aura:if isTrue ="{!v.openmodal2}">
             <div role="dialog" aura:id="Modalbox6" class="slds-modal slds-fade-in-open ">
                <div class="slds-modal__container">
                    <div class="slds-modal__header">
                        
                        <h1 class="slds-text-heading--medium">Change Product Build</h1>
                    </div>
                     
                    <!--Modal Box Header-->
                    <div class="slds-modal__content slds-p-around--medium">
                        <center> <p><b>
                           <iframe src ="{!'/apex/SVC_Product_Build_Incident_Link?id='+v.recordId+'&amp;source=SVC_Product_Build__c&amp;type=ticket'}" width="100%" height="500px;" frameBorder="0"/>
                            </b>
                            </p></center>
                    </div>
                    <!--Modal Box Button-->
                    <div class="slds-modal__footer">
                        <button class="slds-button slds-button--brand" onclick="{!c.closing}">Close</button>
                    </div>
                </div>
            </div>
            <div class="slds-backdrop slds-backdrop--open" aura:id="Modalbackdrop6"> 
             </div>
             </aura:if>
             
             

                </lightning:layoutItem>                 
                          
          
          
           
            </lightning:layout>
          
         
               <lightning:layout horizontalAlign="left">
           <lightning:layoutItem size="12">
             <lightning:inputField aura:id="newOpportunityField" fieldName="System_Version__c" required ="true" onchange="{!c.productChanged}"/>
            <a href="javascript:void(0)" iconPosition ="left">Change</a>
               
             <aura:if isTrue ="{!v.openmodal4}">
             <div role="dialog" aura:id="Modalbox8" class="slds-modal slds-fade-in-open ">
                <div class="slds-modal__container">
                    <div class="slds-modal__header">
                        
                        <h1 class="slds-text-heading--medium">Change System Version</h1>
                    </div>
                     
                    <!--Modal Box Header-->
                    <div class="slds-modal__content slds-p-around--medium">
                        <center> <p><b>
                           <iframe src ="{!'/apex/SVC_Product_Build_Link?id='+v.recordId+'&amp;source=SVC_Product_Build__c&amp;type=ticket'}" width="100%" height="500px;" frameBorder="0"/>
                            </b>
                            </p></center>
                    </div>
                    <!--Modal Box Button-->
                    <div class="slds-modal__footer">
                        <button class="slds-button slds-button--brand" onclick="{!c.closing1}">Close</button>
                    </div>
                </div>
            </div>
            <div class="slds-backdrop slds-backdrop--open" aura:id="Modalbackdrop8"> 
             </div>
             </aura:if>

                </lightning:layoutItem>                 
                          
          
          
           
            </lightning:layout> 
          
          
          <lightning:combobox aura:id="selectItem" fieldName="Feature_Function__c" label="Failure Point"
                        placeholder="Choose Failure Point"
                        value="name"
                        required="true"
                        dropdownAlignment="right"
                        variant="standard"
                        messageWhenValueMissing="Complete this field"
                        onchange="{!c.handleOptionSelected}"
                        options="{!v.featureOptions}"/>
         
           <lightning:inputField aura:id="newOpportunityField" fieldName="SolvedBy__c" required ="true" />
         
          
           <lightning:inputField aura:id="newOpportunityField" fieldName="CauseCodeCategory__c" required ="true" />
            
           <lightning:inputField aura:id="newOpportunityField" fieldName="CauseCodeDetail__c" required ="true"/>
            <br/>
            <br/>
            <br/>
            <br/>
            <br/><br/>
            
            
            </aura:if>
             
            </lightning:recordEditForm>
                 

controller:
handleOptionSelected : function(component,event,helper){
        
        
         
        var selectedOptionValue = event.getParam("value");
        let ticket = component.get("v.ticket.Feature_Function__c");
        ticket = selectedOptionValue;
        component.set("v.ticket.Feature_Function__c",ticket);
      
        
        
               
    }

failurePointList: function(component, event, helper) {
        
       var productid = component.get("v.ticket.Product__c");
        var action = component.get("c.getFeatureFunction");
        if(productid != 'undefined' && productid !=null){
        action.setParams({
            productId: productid
 
            
        });
       
             action.setCallback(this,function(response){
                 var res = response.getReturnValue();
                 console.log('template object::'+JSON.stringify(response.getReturnValue()));
                 var state = response.getState();
                 if(state == "SUCCESS"){
                     var lables= [];
                     res.forEach(function(key) {
                         lables.push({"label":key.Name ,"value":key.Id});
                     });
                    
                     component.set("v.featureOptions", lables);
                  
                 }
             });
             $A.enqueueAction(action);
        }  
    }

i am submitting the fields when i click next button likr

 event.preventDefault();
            
           var eventFields = event.getParam("fields");
                    
    
        component.find('leadCreateForm1').submit(eventFields);
Hi i have command button when clicked its overriding the page instead i need to open it in its own subtab  in lightning.

<apex:commandButton value="Clone Package To Selected CRs" action="{!clonePackageToChangeRequests}" reRender="pbId" status="fetchStatus" rendered="{!NOT(isCompleted)}"/>

Controller:
public PageReference clonePackageToChangeRequests() {
        Savepoint sp = Database.setSavepoint();
        try {
            Set<ID> crIds = new Set<ID>();
            for (SelectableChangeRequest record : changeRequests) {
            if(record.selected && record.obj.Customer_Packages__r.size() > 0) { //TKT-1239114
                 
                
              throw new CloneChangeRequestException(EXCEPTION_NAME);
            }else if (record.selected) {
                   crIds.add(record.obj.Id);
                    
                }
            }

            if (crIds.size() > 0) {
                return handleSuccess(SVC_CR_Package_Service.clonePackage(crIds, crPackage.Id));
            }
        } catch (Exception e) {
            Database.rollback(sp);
            ApexPages.addMessage(SVC_ErrorHandler.logAndConvertToApexMessage(e));
        }

        return null;
    }

 private PageReference redirect(ID recordId) {
        PageReference retURL = new PageReference('/' + recordId);
        retURL.setRedirect(true);
        return retURL;
 
           }
I read more articles on this but i couldnt find the  solution since there is a condition that if the package is present it should throw exception and if not it clones the package and should open that package in subtab..Can anyone help me with this code.

Hi,

I have a lightning combobox which displays based on the product field value in case..i have like v.ticket.Product__c..but when the product value gets changed the picklist values are not getting updated..it just shows the old value...can anyone help with this..

<lightning:combobox aura:id="selectItem" fieldName="Feature_Function__c" label="Failure Point"
                        placeholder="Choose Failure Point"
                        value="name"
                        required="true"
                        dropdownAlignment="right"
                        variant="standard"
                        messageWhenValueMissing="Complete this field"
                        onchange="{!c.handleOptionSelected}"
                        options="{!v.featureOptions}"/>

js con:

var productid = component.get("v.ticket.Product__c");
        var action = component.get("c.getFeatureFunction");
        if(productid != 'undefined' && productid !=null){
        action.setParams({
            productId: productid
 
            
        });
       
             action.setCallback(this,function(response){
                 var res = response.getReturnValue();
                 console.log('template object::'+JSON.stringify(response.getReturnValue()));
                 var state = response.getState();
                 if(state == "SUCCESS"){
                     var lables= [];
                     res.forEach(function(key) {
                         lables.push({"label":key.Name ,"value":key.Id});
                         $A.get('e.force:refreshView').fire();
                     });
                    
                     component.set("v.featureOptions", lables);
                     $A.get('e.force:refreshView').fire();
                  
                 }
             });
             $A.enqueueAction(action);
        } 

apex:
@AuraEnabled
     public static List<SVC_Feature_Function__c> getFeatureFunction(String productId){
         
        return [SELECT Id, Name FROM SVC_Feature_Function__c Where Product__c =:productId order by Name asc];
         
    }
Hi,
I have lightning combox with filters depends on product value..
I am getting the picklist values in the form.
But when the product field is chnaged in case object..the picklist values are not getting refreshed and instead shows the values for old product value.

once value get selected..i should right to v.ticket.Feature_function__c

How to refresh the lightning combobox values:
Apex controller
 @AuraEnabled
     public static List<SVC_Feature_Function__c> getFeatureFunction(String productId){
         
        return [SELECT Id, Name FROM SVC_Feature_Function__c Where Product__c =:productId order by Name asc];
         
    }

Component:
 <lightning:combobox aura:id="newOpportunityField" fieldName="Feature_Function__c" label="Failure Point"
                        placeholder="Choose Failure Point"
                        value="{!v.ticket.Feature_Function__c}"
                        required="true"
                        dropdownAlignment="right"
                        variant="standard"
                        messageWhenValueMissing="Complete this field"
                        onchange="{!c.handleOptionSelected}"
                        options="{!v.featureOptions}"/>
js controller:
failurePointList: function(component, event, helper) {
        
       
        var action = component.get("c.getFeatureFunction");
        action.setParams({
            productId: component.get("v.ticket.Product__c")
        });
             action.setCallback(this,function(response){
                 var res = response.getReturnValue();
                 console.log('ticket object::'+JSON.stringify(response.getReturnValue()));
                 var state = response.getState();
                 if(state == "SUCCESS"){
                     var lables= [];
                     res.forEach(function(key) {
                         lables.push({"label":key.Name ,"value":key.Id});
                         
                     });
                     
                     component.set("v.featureOptions", lables);
                   
                 }
             });
             $A.enqueueAction(action);
           
    },

Can anyone help to refresh the values in picklist if product value changed in case object..
Hi i have a lightning combobox..I need help how to get the options from the query
Apex controller:
  @AuraEnabled 
    public static List<SVC_Feature_Function__c> getRecords(String productId){
        return [SELECT Id, Name FROM SVC_Feature_Function__c Where Product__c =:productId];
    }

Component:
<aura:attribute name="statusOptions" type="List" default="[]"/>
<aura:attribute name="ticket" type="Object" access="private"/>
<force:recordData aura:id="recordLoader"
                      recordId="{!v.recordId}"
                      fields="Id,Subject,CaseNumber,Information_Request_Type__c,Open_Tasks__c,RecordTypeId,Product_Build__c,System__c,Total_Work_Time__c,Flagged_for_KB_Review__c,Product__c,Feature_Function__c,Solution__c,SolvedBy__c,CauseCodeDetail__c,CauseCodeCategory__c,Billable__c,MajorIncident__c,Ready_to_Resolve_MI__c,Billing_Hours__c,Billing_Comments__c,Billing_Disposition__c"
                      targetFields="{!v.ticket}"
    />
   
<lightning:combobox aura:id="selectItem" name="Failure Point" label="Failure Point"
                        placeholder="Choose Failure Point"
                        value="new"
                        required="true"
                        dropdownAlignment="right"
                        variant="standard"
                        messageWhenValueMissing="You Must Select the Value"
                        onchange="{!c.handleOptionSelected}"
                        options="{!v.statusOptions}"/>

Js controller:

How to write js controller code to get the options and handle change when option selected to save to the ticket.
Hi,

I have a lookup field named failure point in case object.

I created a aura lightning component  where I need to add failure point as a picklist field based on the product value selected in case object(filter,)
I have values v.recordId and v.tickev.ticket.__c in my code.

How can u achieve this
Hi,

I am trying to detach a article from case when clicking the button in lightning component..how to achieve this.

Apex class:
@AuraEnabled
    public static String detachArticleToCases(String caseId, String articleId){
       List<CaseArticle> searchCaseArticleList =[select Id from CaseArticle where CaseID =:caseId];
          
String message = 'SUCCESS';
  if (searchCaseArticleList.size() > 0){
      CaseArticle ca = new CaseArticle(); 
      ca.CaseID = caseId; 
      ca.KnowledgeArticleId = articleId; 
      delete ca; 
  } 

  
return message;

    }

Aura component:
<aura:iteration items="{!v.Knowledge__kav}" var="Knowledge__kav">
                <tr>  
                  
                    <td><div class="slds-truncate" title="{!Knowledge__kav.ArticleNumber}">{!Knowledge__kav.ArticleNumber}</div></td>   
                    <td><div class="slds-truncate" title="{!Knowledge__kav.Title}">{!Knowledge__kav.Title}</div></td>
                    
                    <td><div class="slds-truncate" title="{!Knowledge__kav.System__r.Name}">{!Knowledge__kav.System__r.Name}</div></td>
                    <td><div class="slds-truncate" title="{!Knowledge__kav.Product__r.Name}">{!Knowledge__kav.Product__r.Name}</div></td>
                     <td><div class="slds-truncate" title="{!Knowledge__kav.LastPublishedDate}">{!Knowledge__kav.LastPublishedDate}</div></td>
                    <td><div class="slds-truncate" title="{!Knowledge__kav.Version__c}">{!Knowledge__kav.Version__c}</div></td>
                    <lightning:button variant="brand-outline"  label="Attach" onclick="{!c.handleClick}" value="{!Knowledge__kav.KnowledgeArticleId}"/> 
                    <lightning:button variant="brand-outline"  label="Detach" onclick="{!c.handleClick1}" value="{!Knowledge__kav.KnowledgeArticleId}"/>
                                    
                </tr>
            </aura:iteration>

Controller:
 handleClick1 : function(component, event, helper) {
        var action = component.get('c.detachArticleToCases');
       let recordId = component.get("v.recordId");
     var KnowledgeArticleId = event.getSource().get("v.value");
      
       action.setParams({
            caseId:recordId,  // Make sure your component implemented force:hasRecordId interface
           articleId: KnowledgeArticleId 
       });
       action.setCallback(this,function(a){
         var state = a.getState(); // get the response state
           if(state == 'SUCCESS') {
              var toastEvent = $A.get("e.force:showToast");
        toastEvent.setParams({
                        "title": "Success!",
                        "message": "Article detached from case",
                        "type": "success"
                    });
        toastEvent.fire();
            }
           else{
               var toastEvent = $A.get("e.force:showToast");
        toastEvent.setParams({
                        "title": "Error!",
                        "message": "error",
                        "type": "Error"
                    });
        toastEvent.fire();
           }
        });
        $A.enqueueAction(action);
       $A.get('e.force:refreshView').fire();
    },
Hi,

I have a case trigger.when creating a case based on the value given in these fields I need to autopopulate two other fields.

Account--user entered
Product--user entered
system-user entered
Environment --user entered

We need to autopopulate 
ticket.productbuild =
Ticket.system version=

these vales comes from
svc-product-build is another object with lookup account .
User-added image
this is the account where installed product name value should diplay in product build and installed system should get display in system version ..
where this table comes from svc product build object with account as a lookup.
for example if environment given as production in case and product as ABS in case it should lookup this table for tat account entered while creating a case..it should match and autopopulate value in those fields
Need to fetch values of product build and system version from svc product build object with account as a lookup.

It's very challenging. Can anyone help with this autopopulation of fields

can anyone help me with this trigger
Hi,

I have a case trigger.when creating a case based on the value given in these fields I need to autopopulate two other fields.

Account--user entered
Product--user entered
system-user entered
Environment --user entered

We need to autopopulate 
ticket.productbuild =
Ticket.system version=

These values comes from account.
svc-product-build is another object with lookup account .

Need to fetch values of product build and system version from svc product build object with account as a lookup.

It's very challenging. Can anyone help with this autopopulation of fields
Hi,

I have a apex command button when it is clicked it check for condition in controller if false it throws exception in same page and if true it opens the another page but it overrides the same page..i need to open that page in subtab ..
Can anyone help me modify my code based on conditions.
Controller:
public PageReference clonePackageToChangeRequests() {
        
        Savepoint sp = Database.setSavepoint();
        try {
            Set<ID> crIds = new Set<ID>();
            for (SelectableChangeRequest record : changeRequests) {
                 
            if(record.selected && record.obj.Customer_Packages__r.size() > 0 ) { //TKT-1239114
              
                
              throw new CloneChangeRequestException(EXCEPTION_NAME);
                
               
            }else if (record.selected) {
               
                   crIds.add(record.obj.Id);
                
                    
                }
            }

            if (crIds.size() > 0) {
               
                return handleSuccess(SVC_CR_Package_Service.clonePackage(crIds, crPackage.Id));
               
            }
        } catch (Exception e) {
            Database.rollback(sp);
            ApexPages.addMessage(SVC_ErrorHandler.logAndConvertToApexMessage(e));
        }

        return null;
    }
  private PageReference redirect(ID recordId) {
       
        PageReference retURL = new PageReference('/' + recordId);
       
        retURL.setRedirect(true);
         
        return retURL;
       
 
           }
VF page:
<apex:commandButton value="Back" action="{!cancel}" immediate="true"/>
                <apex:commandLink action="{!clonePackageToChangeRequests}" >
       <apex:commandButton value="Clone Package To Selected CRs" />
</apex:commandLink>
Hi,

In my code i have the whole object SVC_Change_Request__c in wrapper class.But i need to pass only the Id of  SVC_Change_Request__c and map it with other fields of that object like
Map<ID,SVC_Change_Request__c > and getting that map populated in getchangerequests method in  controller code.and using that getting the value for the table in Visualforce page.How to achieve this.
Controller:
public with sharing class SVC_CR_CloneCRPackage_Ctl {
    private final static List<String> EXCLUDED_STATUSES = new List<String>{
            'Closed', 'Cancelled'
    };
     public string targetValue {get; set;}   
    private final static String EXCEPTION_NAME = 'Package already exists. Please delete the current package before cloning.';//TKT-1239114
public string url {get;set;}
    public Boolean isCompleted { get; set; }
    public Boolean getRelatedAccountOnly { get; set; }
    public SelectableChangeRequest[] changeRequests { get; set; }
    private SVC_CP_QueryBuilder changeRequestsQB;
    private SVC_CR_Package__c crPackage;
   
    public SVC_CR_CloneCRPackage_Ctl() {
         targetValue = '_blank';
        getRelatedAccountOnly = true;
        isCompleted = false;
        crPackage = getCrPackage();
        changeRequests = getChangeRequests();
    }

    private class CloneChangeRequestException extends Exception {}

    /**
     * Clones cr package to selected change requests
     */
    public PageReference clonePackageToChangeRequests() {
        
        Savepoint sp = Database.setSavepoint();
        try {
            Set<ID> crIds = new Set<ID>();
            for (SelectableChangeRequest record : changeRequests) {
                 
            if(record.selected && record.obj.Customer_Packages__r.size() > 0 ) { //TKT-1239114
              
                
              throw new CloneChangeRequestException(EXCEPTION_NAME);
                
               
            }else if (record.selected) {
               
                   crIds.add(record.obj.Id);
                
                    
                }
            }

            if (crIds.size() > 0) {
               
                return handleSuccess(SVC_CR_Package_Service.clonePackage(crIds, crPackage.Id));
               
            }
        } catch (Exception e) {
            Database.rollback(sp);
            ApexPages.addMessage(SVC_ErrorHandler.logAndConvertToApexMessage(e));
        }

        return null;
    }

    /**
     * Redirects to new package if there is one,
     * Displays list of new packages if there are many
     */
    private PageReference handleSuccess(SVC_CR_Package__c[] newPackages) {
        if (newPackages.size() == 1) {
           
            return redirect(newPackages[0].Id);
        }

        showSuccess(newPackages);
        return null;
    }

    /**
     * Displays success message with list of new packages
     */
    private void showSuccess(SVC_CR_Package__c[] newPackages) {
        for (SVC_CR_Package__c record : newPackages) {
            String message = Label.SVC_CR_ClonedPackages.replace('{0}', '/' + record.Id)
                    .replace('{1}', record.Name);

            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.INFO, message));
        }
        ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.CONFIRM, Label.SVC_CR_ClonedPackageSuccess));
        isCompleted = true;
    }

    /**
     * Redirects back to Opportunity record
     */
    public PageReference cancel() {
        return redirect(crPackage.Id);
    }

    /**
     * Displays only change requests that has Account related to Opportunity
     */
    public void withRelatedAccount() {
        getRelatedAccountOnly = true;
        changeRequests = getChangeRequests();
    }

    /**
     * Displays all change requests
     */
    public void withAllAccounts() {
        getRelatedAccountOnly = false;
        changeRequests = getChangeRequests();
    }

    /**
     * Redirects to cr package page
     */
    private PageReference redirect(ID recordId) {
       
        PageReference retURL = new PageReference('/' + recordId);
       
        retURL.setRedirect(true);
         
        return retURL;
       
 
           }

    /**
     * Queries cr package record
     */
    private SVC_CR_Package__c getCrPackage() {
        return (SVC_CR_Package__c) SVC_CP_QueryBuilder.getInstance(SVC_CR_Package__c.SObjectType)
                .withAllFields()
                .withField('Change_Request__r.Opportunity__c')
                .withField('Change_Request__r.Account__r.Name')
                .withField('Change_Request__r.Account__r.Systems_Parent__c')
                .andWhereEq(SVC_CR_Package__c.Id, ApexPages.currentPage().getParameters().get('packageId'))
                .queryOne();
    }

    /**
     * Queries change requests
     */

    Private SelectableChangeRequest[] getChangeRequests() {
        SVC_CP_QueryBuilder changeRequestsQB = SVC_CP_QueryBuilder.getInstance(SVC_Change_Request__c.SObjectType)
                .withAllFields()
                .withFields(new String[]{
                        'Account__c', 'Account__r.Name', 'Account__r.Systems_Parent__c', 'Opportunity__c', 'Opportunity__r.Name', 'Change_Owner__c', 'Change_Owner__r.Name'
                })
                .withSubquery('Customer_Packages__r', SVC_CP_QueryBuilder.getInstance(SVC_CR_Package__c.SObjectType))//TKT-1239114
                .andWhereEq(SVC_Change_Request__c.RecordTypeId, SVC_CR_ChangeRequestService.getInstance().getProjectRecordTypeId())

//                .andWhereNotIn(
//                        SVC_Change_Request__c.Id,
//                        SVC_CP_QueryBuilder.getInstance(SVC_CR_Package__c.SObjectType)
//                                .withField(SVC_CR_Package__c.Change_Request__c)
//                                .andWhereNotIn('Change_Request__r.Status__c', EXCLUDED_STATUSES)
//                )
                .andWhereNotIn(SVC_Change_Request__c.Status__c, EXCLUDED_STATUSES);

        if (getRelatedAccountOnly) {
            Set<ID> relatedAccountIds = new Set<ID>{
                    crPackage.Change_Request__r.Account__c
            };
            if (crPackage.Change_Request__r.Account__r.Systems_Parent__c != null) {
                relatedAccountIds.add(crPackage.Change_Request__r.Account__r.Systems_Parent__c);
            }

            SVC_CP_ConditionBuilder conditionBuilder = SVC_CP_ConditionBuilder.getInstance();
            SVC_CP_ConditionBuilder.Condition[] conditions = new SVC_CP_ConditionBuilder.Condition[]{};
            conditions.add(conditionBuilder.includes('Account__r.Systems_Parent__c', relatedAccountIds));
            conditions.add(conditionBuilder.includes('Account__c', relatedAccountIds));
            changeRequestsQB.andWhere(conditionBuilder.dis(conditions));//TKT-1242443
        }

        SVC_Change_Request__c[] changeRequests = (SVC_Change_Request__c[]) changeRequestsQB.queryList();
        SelectableChangeRequest[] crs = new SelectableChangeRequest[]{
        };
           
        for (SVC_Change_Request__c cr : changeRequests) {
            crs.add(new SelectableChangeRequest(cr));

        }

        return crs;
    }

    public class SelectableChangeRequest {
        public Boolean selected { get; set; }
        //public ID changeRequestId { get;set; }
        public SVC_Change_Request__c obj { get; set; }
 
        
        public SelectableChangeRequest(SVC_Change_Request__c obj) {
            
        this.obj=obj;
        this.selected = false;
        }
    }
}
VF page:
<apex:page controller="SVC_CR_CloneCRPackage_Ctl">
   
    <apex:stylesheet value="{!URLFOR($Resource.BugPagination, 'DataTable/CSS/jquery.dataTables.min.css')}"/>
    <apex:stylesheet value="{!URLFOR($Resource.BugPagination, 'DataTable/ExternalCSS/ExternalCSS.css')}"/>
    <style>
        .message .messageText a {
            margin: 0;
            font-size: 100%;
        }
    </style>

    <script type="text/javascript" language="javascript"
            src="{!URLFOR($Resource.BugPagination, 'DataTable/JS/jquery-1.10.2.min.js')}"></script>
    <script type="text/javascript" language="javascript"
            src="{!URLFOR($Resource.BugPagination, 'DataTable/JS/jquery.dataTables.min.js')}"></script>
    <apex:includeScript value="/support/console/29.0/integration.js"/>
    <script type="text/javascript" language="javascript">
        var j$ = jQuery.noConflict();
        j$(document).ready(function() {
            initTable();
        });

        var initTable = function() {
            j$('table.dataTable').dataTable({
                "bPaginate" : true,
                "bLengthChange" : true,
                "bFilter" : true,
                "bSort" : true,
                "bInfo" : true,
                "bAutoWidth" : false,
                "scrollY": "500px",
                "columnDefs": [
                    { "orderable": false, "targets": 0 },
                ]
            });
        };
                  
                    </script>
  
    <apex:form >
        <apex:pageblock id="pbId">
            <apex:pageMessages escape="false" id="messages"/>
            <apex:pageBlockButtons id="PgButtons">
               <apex:commandButton value="Back" action="{!cancel}" immediate="true"/>
                <apex:commandLink action="{!clonePackageToChangeRequests}" target="{!targetValue}" >
       <apex:commandButton value="Clone Package To Selected CRs" />
</apex:commandLink>
    <!--  <apex:commandButton value="Clone Package To Selected CRs" action="{!clonePackageToChangeRequests}" reRender="pbId" status="fetchStatus" rendered="{!NOT(isCompleted)}"/>-->
            
            </apex:pageBlockButtons>

            <apex:outputPanel >
                <apex:actionStatus id="fetchStatus">
                    <apex:facet name="start">
                        <img src="/img/loading.gif"/>
                    </apex:facet>
                </apex:actionStatus>
            </apex:outputPanel>
             <apex:pageBlockSection id="pageSection" columns="1" rendered="{!NOT(isCompleted)}">
                <apex:outputPanel id="accountFilters">
                    <apex:commandLink action="{!withRelatedAccount}" value="Show related Account" id="relatedAccountLink" rendered="{!!getRelatedAccountOnly}"
                                      reRender="pageSection" status="fetchStatus" onComplete="initTable();"/>
                    
                   <apex:commandLink action="{!withAllAccounts}" value="Show all Accounts" id="allAccountsLink" rendered="{!getRelatedAccountOnly}"
                                      reRender="pageSection" status="fetchStatus" onComplete="initTable();"/>
                </apex:outputPanel>
                     
<apex:pageblockTable id="crTable" value="{!changeRequests}" var="item" styleClass="dataTable">
           <apex:column id="row">
                         <apex:inputCheckbox id="selectBox" value="{!item.selected}"/>
          </apex:column>
          <apex:column >
                        <apex:facet name="header">Change Request</apex:facet>
                        
                        <apex:outputLink value="/{!item.obj.Id}">{!item.obj.Name}</apex:outputLink>
          </apex:column>     
     
        <apex:repeat value="{!$ObjectType.SVC_Change_Request__c.FieldSets.PackageCloneListView}" var="f">
        <apex:column value="{!item.obj[f]}"/>
         </apex:repeat>
                   </apex:pageblockTable>           

         </apex:pageBlockSection>
        </apex:pageblock>
    </apex:form>
</apex:page>
 
Hi i have a table displays the recentlr created record..i need to refresh the table..how to achieve it?
Component:

<aura:if isTrue="{!v.ticket.Total_Work_Time__c == 0}">
                    <div>
                        <div role="dialog" aura:id="Modalbox" class="slds-modal slds-fade-in-open ">
               <div class="slds-modal__container">
                  
                    
                            
                   <div class="slds-m-around--xx-large">
                       
        <lightning:card title="Work Time" iconName="custom:custom86" class="slds-p-around_medium">
            <br/>
            <div class="slds-m-around_xx-small">
        <div class="slds-align--absolute-left">
        <h1 class="slds-text-heading--small">No Existing Work Time Entries Found. Please add below:</h1>
        </div>
            </div>
            <br/>
            <lightning:recordEditForm aura:id="leadCreateForm2"  objectApiName="SVC_Work_Time__c">
                <lightning:messages />

                <lightning:inputField aura:id="lookup" fieldName="Ticket__c" value="{!v.recordId}"></lightning:inputField>
                   
                    
                        <lightning:inputField fieldName="Work_Date__c"></lightning:inputField>
                    
               
                        <lightning:inputField fieldName="User__c"></lightning:inputField>
                    
               
                        <lightning:inputField fieldName="Minutes__c"></lightning:inputField>
                    
                  
                        <lightning:inputField fieldName="After_Hours__c"></lightning:inputField>
                    
                          
                        <lightning:inputField fieldName="Reason__c"></lightning:inputField>
                    
               
                <br/><br/><br/>
                <center>
                 
                <lightning:button type="submit" label="Save" variant="brand" onclick="{!c.handleOnSubmit}"/>
                  
                    <lightning:button  label="Save and New"  variant="brand"/>
                  
                <lightning:button  label="Close" onclick="{!c.closemodal}" variant="brand"/>
                   
                </center>
            </lightning:recordEditForm>
        </lightning:card>
    </div>
                </div>
            </div>
            <div class="slds-backdrop slds-backdrop--open" aura:id="Modalbackdrop"> 
             </div>
         
                    
                  </div>
        <aura:set attribute="else">    
    <div class="slds-m-around_xx-small">
        <div class="slds-align--absolute-left">
        <h1 class="slds-text-heading--small">Below are the 5 most recent work time entries</h1>
            <br/>
        </div>
                </div>
                             
                            <table class="slds-table slds-table_bordered slds-table_cell-buffer">
        <thead>
            <tr class="slds-text-title--caps">
                
                <th scope="col"><div class="slds-truncate" title="Id">S.No</div></th>
               
                <th scope="col"><div class="slds-truncate" title="Work Date">Work Date</div></th>
                <th scope="col"><div class="slds-truncate" title="User">User</div></th>
                <th scope="col"><div class="slds-truncate" title="Minutes">Minutes</div></th>
                <th scope="col"><div class="slds-truncate" title="After Hours">After Hours</div></th>
                <th scope="col"><div class="slds-truncate" title="Reason">Reason</div></th>
                
                
            </tr>
        </thead>          
        <tbody>
    
               <aura:iteration items="{!v.timeList}" var="time" indexVar="sNo"  >
              
                       
             
                   <c:Inlinechildtime single="{!time}"  sNo="{!sNo + 1}"/>
                   
            </aura:iteration>
            </tbody>
            </table>
                            <br/>
                            <br/>
                            <center>
                            <div class="slds-m-around_xx-small">
        <div class="slds-align--absolute-Center">
        <h1 class="slds-text-heading--small">Do you need to add any additional work time?</h1>
            <br/>
            <br>
            </br>
            <br>
            </br>
        </div>
                </div>
                            
                    <button class="slds-button slds-button_success" type ="submit" onclick="{!c.actionhandler2}"  >Yes</button>
                                

                            <button class="slds-button slds-button_destructive" onclick="{!c.handleNext1}">No</button>
                                <br/>
                                <br/>
                                <br/>
                                <br/><br/>
                                <br/>
                                <br/><br/><br/><br/>
                           
            <aura:if isTrue="{!v.seeu}">
 <div role="dialog" aura:id="Modalbox" class="slds-modal slds-fade-in-open ">
               <div class="slds-modal__container">
                   
                   <div class="slds-m-around--xx-large">
                       
        <lightning:card title="Work Time" iconName="custom:custom86" class="slds-p-around_medium">
            <br/>
            <lightning:recordEditForm aura:id="leadCreateForm2"  objectApiName="SVC_Work_Time__c">
                <lightning:messages />
                 
                <lightning:inputField fieldName="Ticket__c" value="{!v.recordId}"></lightning:inputField>
                        <lightning:inputField aura:id="lookup" fieldName="Work_Date__c"></lightning:inputField>
                   
                   
                        <lightning:inputField aura:id="lookup" fieldName="User__c"></lightning:inputField>
               
               
                        <lightning:inputField aura:id="lookup" fieldName="Minutes__c"></lightning:inputField>
                  
                   
                        <lightning:inputField aura:id="lookup" fieldName="After_Hours__c"></lightning:inputField>
                
                          
                        <lightning:inputField aura:id="lookup" fieldName="Reason__c"></lightning:inputField>
                  <br/><br/><br/>
                <center>
                 
                <lightning:button type="submit" label="Save" variant="brand" onclick="{!c.handleOnSubmit}"/>
                    <lightning:button type="submit" label="Save and New"  variant="brand" onclick="{!c.handleOnSubmit2}"/> 
                <lightning:button  label="Close" onclick="{!c.closemodal}" variant="brand"/>
                </center>
            </lightning:recordEditForm>
        </lightning:card>
    </div>
                </div>
            </div>
            <div class="slds-backdrop slds-backdrop--open" aura:id="Modalbackdrop"> 
             </div>
         
          </aura:if>     


Controller:
var action = component.get("c.fetchtime");
       var recordId = component.get("v.recordId");
        
        action.setParams({
           recordId : recordId
            
            
            
                   });
        action.setCallback(this, function(response) {
            var state = response.getState();
            if (state === "SUCCESS") {
                var storeResponse = response.getReturnValue();                
                component.set("v.timeList", storeResponse);
                $A.get('e.force:refreshView').fire();
            }
        });
        $A.enqueueAction(action);
         $A.get('e.force:refreshView').fire();  
       },
I tried $A.get('e.force:refreshView').fire(); but it didnt refresh
Hi i have lightning progressive indicator with step 1 to step 5..

if the status of ticket task is closed or there are no tasks then step 1 should be skipped..

How to get that condition??

I have my component in case object and i have v.recordId..

How to get the value of ticket task status.

Ticket task object name is SVC_ticket_task__c
public static List<SVC_Ticket_Task__c>  fetchAccts(String recordId){
    
    
    return [SELECT Id,Ticket__r.Id, Name,Short_Description__c,Type__c,Status__c,Owner__r.Name,Engineer__r.Name from SVC_Ticket_Task__c where Status__c != 'Closed' AND Ticket__r.Id  =:recordId];

here the status should be closed and if there are no task then the first step should be skipped and if not it displays the open task in first step..

Can anyone help me with this conditional code..its urgent
Hi,

I have a search bar to search the articles and a attach button in each row.
I can attach the article to case.IT is working fine.But i attaches multiple attachments..
When attach button is clicked it should insert the article and if again another attach button is clicked the inserted row should get deleted and newly clicked row should be inserted..and also when it s attached that row should be removed from table and when another row is attached again the old row should again display in table.

Can anyone help me with achieving this..
componennt:

<lightning:input type="text" name="searchKey" label="Enter" aura:id="searchKey" onchange="{!c.searchKeyChange}" placeholder="Search" />          
    <table class="slds-table slds-table_bordered slds-table_striped slds-table_cell-buffer slds-table_fixed-layout">
        <thead>
            <tr class="slds-text-heading_label">              
                <th scope="col"><div class="slds-truncate" title="Title">Article Number</div></th>
                <th scope="col"><div class="slds-truncate" title="Title">Article Title</div></th>
                <th scope="col"><div class="slds-truncate" title="Title">Description</div></th>
               <th scope="col"><div class="slds-truncate" title="Title">System</div></th>
                <th scope="col"><div class="slds-truncate" title="Title">Product</div></th>
                <th scope="col"><div class="slds-truncate" title="Title">LastPublishedDate</div></th>
                <th scope="col"><div class="slds-truncate" title="Title">Version</div></th>
               
                            
            </tr>
        </thead>
        <tbody>
            <aura:iteration items="{!v.Knowledge__kav}" var="Knowledge__kav">
                <tr>  
                  
                    <td><div class="slds-truncate" title="{!Knowledge__kav.ArticleNumber}">{!Knowledge__kav.ArticleNumber}</div></td>   
                    <td><div class="slds-truncate" title="{!Knowledge__kav.Title}">{!Knowledge__kav.Title}</div></td>
                    <td><div class="slds-truncate" title="{!Knowledge__kav.Description_c}">{!Knowledge__kav.Description__c}</div></td>
                   <td><div class="slds-truncate" title="{!Knowledge__kav.System__r.Name}">{!Knowledge__kav.System__r.Name}</div></td>
                    <td><div class="slds-truncate" title="{!Knowledge__kav.Product__r.Name}">{!Knowledge__kav.Product__r.Name}</div></td>
                     <td><div class="slds-truncate" title="{!Knowledge__kav.LastPublishedDate}">{!Knowledge__kav.LastPublishedDate}</div></td>
                    <td><div class="slds-truncate" title="{!Knowledge__kav.Version__c}">{!Knowledge__kav.Version__c}</div></td>
                    <lightning:button variant="brand-outline"  label="Attach" onclick="{!c.handleClick}" value="{!Knowledge__kav.KnowledgeArticleId}"/>                 
                </tr>
            </aura:iteration>
        </tbody>
    </table> 
                                
Controller:
handleClick : function(component, event, helper) {
        var action = component.get('c.attachArticleToCase');
       let recordId = component.get("v.recordId");
     var KnowledgeArticleId = event.getSource().get("v.value");
      
       action.setParams({
            caseId:recordId,  // Make sure your component implemented force:hasRecordId interface
           articleId: KnowledgeArticleId 
       });
       action.setCallback(this,function(a){
         var state = a.getState(); // get the response state
           if(state == 'SUCCESS') {
              var toastEvent = $A.get("e.force:showToast");
        toastEvent.setParams({
                        "title": "Success!",
                        "message": "Article attached to case",
                        "type": "success"
                    });
        toastEvent.fire();
            }
           else{
               var toastEvent = $A.get("e.force:showToast");
        toastEvent.setParams({
                        "title": "Error!",
                        "message": "error",
                        "type": "Error"
                    });
        toastEvent.fire();
           }
        });
        $A.enqueueAction(action);
       $A.get('e.force:refreshView').fire();
    },

Apex:

 @AuraEnabled
    public static List <Knowledge__kav> getAccounts() {
        return [SELECT Id, Title, KnowledgeArticleId,ArticleNumber,Description__c,System__r.Name,Product__r.Name,LastPublishedDate,Version__c FROM Knowledge__kav ORDER BY createdDate ASC LIMIT 10];
    }
    @AuraEnabled
    public static List<Knowledge__kav> findByTitle(String searchKey) {
        String Title =  + searchKey + '%';
        return [SELECT Id, Title, KnowledgeArticleId,ArticleNumber,Description__c,System__r.Name,Product__r.Name,LastPublishedDate,Version__c FROM Knowledge__kav WHERE Title LIKE :Title];

    }

 @AuraEnabled
    public static String attachArticleToCase(String caseId, String articleId){
       
           String message = 'SUCCESS';
          
         
             CaseArticle ca = new CaseArticle();
             ca.CaseId = caseId;
              ca.KnowledgeArticleId = articleId;
               insert ca;
          

       return message;
    }
Hi..

I have conditions for progreesive steps in aura.
I have 3 fields 
 <lightning:recordEditForm recordId ="{!v.recordId}" objectApiName = "Case" aura:id="leadCreateForm" onsubmit="{!c.handleSubmit5}" >
        <lightning:messages />
                                
                                <lightning:inputField aura:id="bill" fieldName="Billing_Disposition__c" required ="true"/>
                               
                     
                                     
        <lightning:inputField aura:id="bill" fieldName="Billing_Hours__c" required ="true"/>
                               
                               
        <lightning:inputField aura:id="bill" fieldName="Billing_Comments__c" required ="true" />
                               
                                <br/>
                                <br/>
                                <br/>
                                
        
        
    </lightning:recordEditForm>

my requirement is if any one of these field is null then this page should display else it should be skipped..

and also if any field has value in record page that field should be skipped in record edit form and only fields with no values should be displayd in page for getting values from user..

how to achieve these two conditions..
Can anyone help me with this..
Hi i have lightning progressive indicator with step 1 to step 5..

My requiremnt is if the status of ticket task is closed or there are no tasks then step 1 should be skipped..

How to get that condition??

I have my component in case object and i have v.recordId..

How to get the value of ticket task status.

Ticket task object name is SVC_ticket_task__c
public static List<SVC_Ticket_Task__c>  fetchAccts(String recordId){
    
    
    return [SELECT Id,Ticket__r.Id, Name,Short_Description__c,Type__c,Status__c,Owner__r.Name,Engineer__r.Name from SVC_Ticket_Task__c where Status__c != 'Closed' AND Ticket__r.Id  =:recordId];

here the status should be closed and if there are no task then the first step should be skipped and if not it displays the open task in first step..

Can anyone help me with this conditional code..its urgent
User-added imagehere if task open table will come in step 1..

so ststus closed or there are no task this step should be skipped..but i am getting page like this
User-added image
Hi,
i have a table inside lightning component..aura iteration items comes from another lightning component..when i add the new record then the table should refresh and display the values..can anyone help me with that..
<div class="slds-m-around_xx-small">
        <div class="slds-align--absolute-left">
        <h1 class="slds-text-heading--small">Below are the 5 most recent work time entries</h1>
            <br/>
        </div>
                </div>
                             
                            <table class="slds-table slds-table_bordered slds-table_cell-buffer">
        <thead>
            <tr class="slds-text-title--caps">
                
                <th scope="col"><div class="slds-truncate" title="Id">S.No</div></th>
               
                <th scope="col"><div class="slds-truncate" title="Work Date">Work Date</div></th>
                <th scope="col"><div class="slds-truncate" title="User">User</div></th>
                <th scope="col"><div class="slds-truncate" title="Minutes">Minutes</div></th>
                <th scope="col"><div class="slds-truncate" title="After Hours">After Hours</div></th>
                <th scope="col"><div class="slds-truncate" title="Reason">Reason</div></th>
                
                
            </tr>
        </thead>          
        <tbody>
    
               <aura:iteration items="{!v.timeList}" var="time" indexVar="sNo"  >
              
                       
             
                   <c:Inlinechildtime single="{!time}"  sNo="{!sNo + 1}"/>
                   
            </aura:iteration>
            </tbody>
            </table>
                            <br/>
                            <br/>
                            <center>
                            <div class="slds-m-around_xx-small">
        <div class="slds-align--absolute-Center">
        <h1 class="slds-text-heading--small">Do you need to add any additional work time?</h1>
            <br/>
            <br>
            </br>
            <br>
            </br>
        </div>
                </div>
                            
                    <button class="slds-button slds-button_success" type ="submit" onclick="{!c.actionhandler2}"  >Yes</button>
                                

                            <button class="slds-button slds-button_destructive" onclick="{!c.handleNext1}">No</button>
                                <br/>
                                <br/>
                                <br/>
                                <br/><br/>
                                <br/>
                                <br/><br/><br/><br/>
                           
            <aura:if isTrue="{!v.seeu}">
 <div role="dialog" aura:id="Modalbox" class="slds-modal slds-fade-in-open ">
               <div class="slds-modal__container">
                   
                   <div class="slds-m-around--xx-large">
                       
        <lightning:card title="Work Time" iconName="custom:custom86" class="slds-p-around_medium">
            <br/>
            <lightning:recordEditForm aura:id="leadCreateForm2"  objectApiName="SVC_Work_Time__c">
                <lightning:messages />
                 
                <lightning:inputField fieldName="Ticket__c" value="{!v.recordId}"></lightning:inputField>
                        <lightning:inputField aura:id="lookup" fieldName="Work_Date__c"></lightning:inputField>
                   
                   
                        <lightning:inputField aura:id="lookup" fieldName="User__c"></lightning:inputField>
               
               
                        <lightning:inputField aura:id="lookup" fieldName="Minutes__c"></lightning:inputField>
                  
                   
                        <lightning:inputField aura:id="lookup" fieldName="After_Hours__c"></lightning:inputField>
                
                          
                        <lightning:inputField aura:id="lookup" fieldName="Reason__c"></lightning:inputField>
                  <br/><br/><br/>
                <center>
                 
                <lightning:button type="submit" label="Save" variant="brand" onclick="{!c.handleOnSubmit}"/>
                    <lightning:button type="submit" label="Save and New"  variant="brand" onclick="{!c.handleOnSubmit2}"/> 
                <lightning:button  label="Close" onclick="{!c.closemodal}" variant="brand"/>
                </center>
            </lightning:recordEditForm>
        </lightning:card>
    </div>
                </div>
            </div>
            <div class="slds-backdrop slds-backdrop--open" aura:id="Modalbackdrop"> 
             </div>
         
          </aura:if>    

how to refresh this table..

thanks 
 
Hi i have a link table which when row is selected it should attach to case.as of now multiple attachments can be done..but my requirement is to attach only one rw..when other row selected old attached row should get deleted and new row should be attcahed ..how can i attach this through trigger or any workaround.
My link table code
Controller:
global with sharing class SVC_Problem_Incident_Ctl extends SVC_Link_Ctl_Helper
{
    /**
     * Class controller
     */
    public SVC_Problem_Incident_Ctl()
    {
        // init class
        init();

        // configure assignments object
        if (sourceObjectName == 'Case') {
            configure('SVC_Incident_Problem_Link__c', 'Problem__c', 'Incident__c');
            
        } else if (sourceObjectName == 'SVC_Problem__c') {
            configure('SVC_Incident_Problem_Link__c', 'Incident__c', 'Problem__c');
        }

        if(sourceObjectName == 'Case') {
            // setup filters object
            filters = new Case(
                // set default status to empty value ...
                Status                     = '',
                // emulates from date filter ...
                Due_Date__c                = Date.today().addDays(-60),
                // emulate to date filter ...
                Estimated_Shipment_Date__c = Date.today()
            );

            // restrict to system / product only
            List<SVC_Problem__c> productList = [SELECT System__c, Product__c FROM SVC_Problem__c WHERE Id = :targetObjectId];
            if (!productList.isEmpty()) {
                if (!String.isEmpty(productList.get(0).System__c)) {
                    selectedSystemId  = productList.get(0).System__c;
                }
                if (!String.isEmpty(productList.get(0).Product__c)) {
                    selectedProductId = productList.get(0).Product__c;
                }
            }
        }
        if (sourceObjectName == 'SVC_Problem__c') {
            List<Case> caseList = [SELECT Actual_System__c, Actual_Product__c FROM Case WHERE Id = :targetObjectId];
            if (!caseList.isEmpty()) {
                selectedSystemId  = caseList.get(0).Actual_System__c;
                selectedProductId = caseList.get(0).Actual_Product__c;
            }
        }
    }

    /**
     * Method returns data matching search critieria
     *
     * @param  params Map of parameters
     * @return        DataTableWrapper object
     */
    @RemoteAction
    global static DataTableWrapper getData(Map<String, String> params)
    {
        // pagination related items
        Integer startVal         = params != null && params.containsKey('start') ? Integer.valueOf(params.get('start')) : 0;
        Integer lengthVal        = params != null && params.containsKey('length') ? Integer.valueOf(params.get('length')) : 10;

        // sorting related items
        String orderBy           = params != null && params.containsKey('orderBy') ? params.get('orderBy') : 'Id';
        String orderDir          = params != null && params.containsKey('orderDir') ? params.get('orderDir') : 'asc';

        // config related items
        String sourceObjectName  = params != null && params.containsKey('sourceObjectName') ? params.get('sourceObjectName') : null;
        String targetObjectId    = params != null && params.containsKey('targetObjectId') ? params.get('targetObjectId') : null;
        String fieldSetName      = params != null && params.containsKey('fieldSetName') ? params.get('fieldSetName') : 'Search_List_Columns';
        Integer draw             = params != null && params.containsKey('draw') ? Integer.valueOf(params.get('draw')) : 0;

        // search value
        String searchValue       = params != null && params.containsKey('search') ? params.get('search') : null;

        // custom args
        String selectedSystemId  = params != null && params.containsKey('selectedSystemId')  ? params.get('selectedSystemId') : null;
        String selectedProductId = params != null && params.containsKey('selectedProductId') ? params.get('selectedProductId') : null;

        // extract filter values
        String status            = params != null && params.containsKey('status') ? params.get('status') : null;
        DateTime fromDate        = params != null && params.containsKey('fromDate') ? SVC_Link_Ctl_Helper.getDateTime(params.get('fromDate')) : null;
        DateTime toDate          = params != null && params.containsKey('toDate') ? SVC_Link_Ctl_Helper.getDateTime(params.get('toDate')) : null;

        // Initialize values
        Integer totalCount       = 0;
        Integer filteredCount    = 0;
        String query             = '';

        if (sourceObjectName == 'SVC_Problem__c') {
            query = 'SELECT ';
            query += ' count() ';
            query += ' FROM ' + sourceObjectName;
            query += ' WHERE ';
                query += ' Id NOT IN (SELECT Problem__c FROM SVC_Incident_Problem_Link__c WHERE Incident__c = :targetObjectId) ';
            if (!String.isEmpty(selectedSystemId)) {
                query += ' AND ';
                    query += ' System__c = :selectedSystemId';
                if (!String.isEmpty(selectedProductId)) {
                    query += ' AND ';
                        query += ' Product__c = :selectedProductId';
                }
            }
        } else if (sourceObjectName == 'Case') {
            Id recordTypeId   = [SELECT Id FROM RecordType WHERE DeveloperName = 'Systems_Incident'].get(0).Id;

            List<String> statuses;
            SVC_General_Service_Settings__c config = SVC_General_Service_Settings__c.getInstance();
            if (status == 'Open') {
                statuses = config.Incident_Status_As_Open__c != null ? config.Incident_Status_As_Open__c.split(',') : new List<String>();
            } else if (status == 'Closed'){
                statuses = config.Incident_Status_As_Closed__c != null ? config.Incident_Status_As_Closed__c.split(',') : new List<String>();
            }

            query = 'SELECT ';
            query += ' count() ';
            query += ' FROM ' + sourceObjectName;
            query += ' WHERE ';
                query += ' Id NOT IN (SELECT Incident__c FROM SVC_Incident_Problem_Link__c WHERE Problem__c = :targetObjectId) ';
            query += ' AND ';
                query += ' RecordTypeId = :recordTypeId';

            // add custom params
            if (statuses != null && !statuses.isEmpty()) {
                query += ' AND ';
                    query += ' Status IN :statuses';
            }
            if (fromDate != null) {
                fromDate = fromDate.addDays(-1);
                query += ' AND ';
                    query += ' CreatedDate > :fromDate';
            }
            if (toDate != null) {
                toDate = toDate.addDays(1);
                query += ' AND ';
                    query += ' CreatedDate < :toDate';
            }
            if (!String.isBlank(selectedSystemId)) {
                query += ' AND ';
                    query += ' System__c = :selectedSystemId';
                if (!String.isBlank(selectedProductId)) {
                    query += ' AND ';
                        query += ' Product__c = :selectedProductId';
                }
            }
        }

        // 10000 is max supported
        totalCount = Database.countQuery(query + ' LIMIT 10000');

        // add search conditions based on user input
        query += SVC_Link_Ctl_Helper.buildSearchString(sourceObjectName, fieldSetName, searchValue);

        // 10000 is max supported
        filteredCount = Database.countQuery(query + ' LIMIT 10000');

        query  = query.replace('count()', SVC_Link_Ctl_Helper.getColumnList(sourceObjectName, fieldSetName));
        // order by requested params
        query += ' ORDER BY ' + orderBy + ' ' + orderDir + (orderDir == 'asc' ? ' NULLS FIRST' : ' NULLS LAST');
        // add limit equal to number of records per page multiplied by current page number so we limit number of records to be processed
        query += ' LIMIT ' + String.valueOf(startVal == 0 ? lengthVal : (startVal + 1) * lengthVal);

        // intialize standard controller with query
        ApexPages.StandardSetController setCon = new ApexPages.StandardSetController(Database.getQueryLocator(query));
        setCon.setPageSize(lengthVal);

        // set page number
        setCon.setPageNumber((startVal / lengthVal) + 1);

        // create wrapper
        return new DataTableWrapper (
            draw,
            totalCount,
            filteredCount,
            setCon.getRecords()
        );
    }
}
Hi.
I have a product build link table which links the product build..i wriiten a trigger for it..but i need to link 3 more fields in case system version,system and product.here system_version system and product are formula fields in link object..how to link it to field in case object
thease are the fields in product build link object
User-added imageController:

global with sharing class SVC_Problem_Incident_Ctl extends SVC_Link_Ctl_Helper
{
    /**
     * Class controller
     */
    public SVC_Problem_Incident_Ctl()
    {
        // init class
        init();

        // configure assignments object
        if (sourceObjectName == 'Case') {
            configure('SVC_Incident_Problem_Link__c', 'Problem__c', 'Incident__c');
        } else if (sourceObjectName == 'SVC_Problem__c') {
            configure('SVC_Incident_Problem_Link__c', 'Incident__c', 'Problem__c');
        }

        if(sourceObjectName == 'Case') {
            // setup filters object
            filters = new Case(
                // set default status to empty value ...
                Status                     = '',
                // emulates from date filter ...
                Due_Date__c                = Date.today().addDays(-60),
                // emulate to date filter ...
                Estimated_Shipment_Date__c = Date.today()
            );

            // restrict to system / product only
            List<SVC_Problem__c> productList = [SELECT System__c, Product__c FROM SVC_Problem__c WHERE Id = :targetObjectId];
            if (!productList.isEmpty()) {
                if (!String.isEmpty(productList.get(0).System__c)) {
                    selectedSystemId  = productList.get(0).System__c;
                }
                if (!String.isEmpty(productList.get(0).Product__c)) {
                    selectedProductId = productList.get(0).Product__c;
                }
            }
        }
        if (sourceObjectName == 'SVC_Problem__c') {
            List<Case> caseList = [SELECT Actual_System__c, Actual_Product__c FROM Case WHERE Id = :targetObjectId];
            if (!caseList.isEmpty()) {
                selectedSystemId  = caseList.get(0).Actual_System__c;
                selectedProductId = caseList.get(0).Actual_Product__c;
            }
        }
    }

    /**
     * Method returns data matching search critieria
     *
     * @param  params Map of parameters
     * @return        DataTableWrapper object
     */
    @RemoteAction
    global static DataTableWrapper getData(Map<String, String> params)
    {
        // pagination related items
        Integer startVal         = params != null && params.containsKey('start') ? Integer.valueOf(params.get('start')) : 0;
        Integer lengthVal        = params != null && params.containsKey('length') ? Integer.valueOf(params.get('length')) : 10;

        // sorting related items
        String orderBy           = params != null && params.containsKey('orderBy') ? params.get('orderBy') : 'Id';
        String orderDir          = params != null && params.containsKey('orderDir') ? params.get('orderDir') : 'asc';

        // config related items
        String sourceObjectName  = params != null && params.containsKey('sourceObjectName') ? params.get('sourceObjectName') : null;
        String targetObjectId    = params != null && params.containsKey('targetObjectId') ? params.get('targetObjectId') : null;
        String fieldSetName      = params != null && params.containsKey('fieldSetName') ? params.get('fieldSetName') : 'Search_List_Columns';
        Integer draw             = params != null && params.containsKey('draw') ? Integer.valueOf(params.get('draw')) : 0;

        // search value
        String searchValue       = params != null && params.containsKey('search') ? params.get('search') : null;

        // custom args
        String selectedSystemId  = params != null && params.containsKey('selectedSystemId')  ? params.get('selectedSystemId') : null;
        String selectedProductId = params != null && params.containsKey('selectedProductId') ? params.get('selectedProductId') : null;

        // extract filter values
        String status            = params != null && params.containsKey('status') ? params.get('status') : null;
        DateTime fromDate        = params != null && params.containsKey('fromDate') ? SVC_Link_Ctl_Helper.getDateTime(params.get('fromDate')) : null;
        DateTime toDate          = params != null && params.containsKey('toDate') ? SVC_Link_Ctl_Helper.getDateTime(params.get('toDate')) : null;

        // Initialize values
        Integer totalCount       = 0;
        Integer filteredCount    = 0;
        String query             = '';

        if (sourceObjectName == 'SVC_Problem__c') {
            query = 'SELECT ';
            query += ' count() ';
            query += ' FROM ' + sourceObjectName;
            query += ' WHERE ';
                query += ' Id NOT IN (SELECT Problem__c FROM SVC_Incident_Problem_Link__c WHERE Incident__c = :targetObjectId) ';
            if (!String.isEmpty(selectedSystemId)) {
                query += ' AND ';
                    query += ' System__c = :selectedSystemId';
                if (!String.isEmpty(selectedProductId)) {
                    query += ' AND ';
                        query += ' Product__c = :selectedProductId';
                }
            }
        } else if (sourceObjectName == 'Case') {
            Id recordTypeId   = [SELECT Id FROM RecordType WHERE DeveloperName = 'Systems_Incident'].get(0).Id;

            List<String> statuses;
            SVC_General_Service_Settings__c config = SVC_General_Service_Settings__c.getInstance();
            if (status == 'Open') {
                statuses = config.Incident_Status_As_Open__c != null ? config.Incident_Status_As_Open__c.split(',') : new List<String>();
            } else if (status == 'Closed'){
                statuses = config.Incident_Status_As_Closed__c != null ? config.Incident_Status_As_Closed__c.split(',') : new List<String>();
            }

            query = 'SELECT ';
            query += ' count() ';
            query += ' FROM ' + sourceObjectName;
            query += ' WHERE ';
                query += ' Id NOT IN (SELECT Incident__c FROM SVC_Incident_Problem_Link__c WHERE Problem__c = :targetObjectId) ';
            query += ' AND ';
                query += ' RecordTypeId = :recordTypeId';

            // add custom params
            if (statuses != null && !statuses.isEmpty()) {
                query += ' AND ';
                    query += ' Status IN :statuses';
            }
            if (fromDate != null) {
                fromDate = fromDate.addDays(-1);
                query += ' AND ';
                    query += ' CreatedDate > :fromDate';
            }
            if (toDate != null) {
                toDate = toDate.addDays(1);
                query += ' AND ';
                    query += ' CreatedDate < :toDate';
            }
            if (!String.isBlank(selectedSystemId)) {
                query += ' AND ';
                    query += ' System__c = :selectedSystemId';
                if (!String.isBlank(selectedProductId)) {
                    query += ' AND ';
                        query += ' Product__c = :selectedProductId';
                }
            }
        }

        // 10000 is max supported
        totalCount = Database.countQuery(query + ' LIMIT 10000');

        // add search conditions based on user input
        query += SVC_Link_Ctl_Helper.buildSearchString(sourceObjectName, fieldSetName, searchValue);

        // 10000 is max supported
        filteredCount = Database.countQuery(query + ' LIMIT 10000');

        query  = query.replace('count()', SVC_Link_Ctl_Helper.getColumnList(sourceObjectName, fieldSetName));
        // order by requested params
        query += ' ORDER BY ' + orderBy + ' ' + orderDir + (orderDir == 'asc' ? ' NULLS FIRST' : ' NULLS LAST');
        // add limit equal to number of records per page multiplied by current page number so we limit number of records to be processed
        query += ' LIMIT ' + String.valueOf(startVal == 0 ? lengthVal : (startVal + 1) * lengthVal);

        // intialize standard controller with query
        ApexPages.StandardSetController setCon = new ApexPages.StandardSetController(Database.getQueryLocator(query));
        setCon.setPageSize(lengthVal);

        // set page number
        setCon.setPageNumber((startVal / lengthVal) + 1);

        // create wrapper
        return new DataTableWrapper (
            draw,
            totalCount,
            filteredCount,
            setCon.getRecords()
        );
    }
}
trigger:

trigger SVC_Ticket_Product_Build_LinkTrigger on SVC_Ticket_Product_Build_Link__c (after insert) {
    if (trigger.isAfter && trigger.isInsert) {
        handleAfterInsert(trigger.new);
    }

    private static void handleAfterInsert(SVC_Ticket_Product_Build_Link__c[] ticketProductBuildLinks) {
        removeExistingLinks(ticketProductBuildLinks);
        updateCaseProductBuild(ticketProductBuildLinks);
    }

    private static void removeExistingLinks(SVC_Ticket_Product_Build_Link__c[] ticketProductBuildLinks) {
        Set<ID> caseIds = new Set<ID>();
        Set<ID> linksIds = new Set<ID>();
        for (SVC_Ticket_Product_Build_Link__c ticketProductBuildLink : ticketProductBuildLinks) {
            caseIds.add(ticketProductBuildLink.Ticket__c);
            linksIds.add(ticketProductBuildLink.Id);
        }

        delete [SELECT Id FROM SVC_Ticket_Product_Build_Link__c WHERE Id NOT IN :linksIds AND Ticket__c IN :caseIds];
    }

    private static void updateCaseProductBuild(SVC_Ticket_Product_Build_Link__c[] ticketProductBuildLinks) {
        Case[] ticketsToUpdate = new Case[]{};
        for (SVC_Ticket_Product_Build_Link__c ticketProductBuildLink : ticketProductBuildLinks) {
            Case ticket = new Case(ID=ticketProductBuildLink.Ticket__c, Product_Build__c=ticketProductBuildLink.Product_Build__c);
            ticketsToUpdate.add(ticket);
        }

        upsert ticketsToUpdate;
    }
}

here product build is linked properly..how to link system, system version ,product .
Hi,

I have a search table when i clicked attach button in each row it attaches the article to the case.But my requirement is to the attached article should be removed from table once it is attached to case and also only one article should be allowed to attach to case..If any other row is selected to attach then old row which is attched should be removed from case and newly added article should get attached to CaseArticle.Can anyone help me with modification of this code??
component:
<lightning:input type="text" name="searchKey" label="Enter" aura:id="searchKey" onchange="{!c.searchKeyChange}" placeholder="Search" />          
    <table class="slds-table slds-table_bordered slds-table_striped slds-table_cell-buffer slds-table_fixed-layout">
        <thead>
            <tr class="slds-text-heading_label">              
                <th scope="col"><div class="slds-truncate" title="Title">Article Number</div></th>
                <th scope="col"><div class="slds-truncate" title="Title">Article Title</div></th>
                <th scope="col"><div class="slds-truncate" title="Title">Description</div></th>
               <th scope="col"><div class="slds-truncate" title="Title">System</div></th>
                <th scope="col"><div class="slds-truncate" title="Title">Product</div></th>
                <th scope="col"><div class="slds-truncate" title="Title">LastPublishedDate</div></th>
                <th scope="col"><div class="slds-truncate" title="Title">Version</div></th>
               
                            
            </tr>
        </thead>
        <tbody>
            <aura:iteration items="{!v.Knowledge__kav}" var="Knowledge__kav">
                <tr>  
                  
                    <td><div class="slds-truncate" title="{!Knowledge__kav.ArticleNumber}">{!Knowledge__kav.ArticleNumber}</div></td>   
                    <td><div class="slds-truncate" title="{!Knowledge__kav.Title}">{!Knowledge__kav.Title}</div></td>
                    <td><div class="slds-truncate" title="{!Knowledge__kav.Description_c}">{!Knowledge__kav.Description__c}</div></td>
                   <td><div class="slds-truncate" title="{!Knowledge__kav.System__r.Name}">{!Knowledge__kav.System__r.Name}</div></td>
                    <td><div class="slds-truncate" title="{!Knowledge__kav.Product__r.Name}">{!Knowledge__kav.Product__r.Name}</div></td>
                     <td><div class="slds-truncate" title="{!Knowledge__kav.LastPublishedDate}">{!Knowledge__kav.LastPublishedDate}</div></td>
                    <td><div class="slds-truncate" title="{!Knowledge__kav.Version__c}">{!Knowledge__kav.Version__c}</div></td>
                    <lightning:button variant="brand-outline"  label="Attach" onclick="{!c.handleClick}" value="{!Knowledge__kav.KnowledgeArticleId}"/>                 
                </tr>
            </aura:iteration>
        </tbody>
    </table> 
                                
Controller:
searchKeyChange: function(component, event) {
        var searchKey = component.find("searchKey").get("v.value");
        console.log('searchKey:::::'+searchKey);
        var action = component.get("c.findByTitle");
        action.setParams({
            "searchKey": searchKey
        });
        action.setCallback(this, function(a) {
            component.set("v.Knowledge__kav", a.getReturnValue());
        });
        $A.enqueueAction(action);
    },   

handleClick : function(component, event, helper) {
        var action = component.get('c.attachArticleToCase');
       let recordId = component.get("v.recordId");
     var KnowledgeArticleId = event.getSource().get("v.value");
      
       action.setParams({
            caseId:recordId,  // Make sure your component implemented force:hasRecordId interface
           articleId: KnowledgeArticleId 
       });
       action.setCallback(this,function(a){
         var state = a.getState(); // get the response state
           if(state == 'SUCCESS') {
              var toastEvent = $A.get("e.force:showToast");
        toastEvent.setParams({
                        "title": "Success!",
                        "message": "Article attached to case",
                        "type": "success"
                    });
        toastEvent.fire();
            }
           else{
               var toastEvent = $A.get("e.force:showToast");
        toastEvent.setParams({
                        "title": "Error!",
                        "message": "error",
                        "type": "Error"
                    });
        toastEvent.fire();
           }
        });
        $A.enqueueAction(action);
       $A.get('e.force:refreshView').fire();
    },

Apex:

@AuraEnabled
    public static String attachArticleToCase(String caseId, String articleId){
       
           String message = 'SUCCESS';
          
         
             CaseArticle ca = new CaseArticle();
             ca.CaseId = caseId;
              ca.KnowledgeArticleId = articleId;
               insert ca;
          

       return message;
    }

 
Hi,

I have a case trigger.when creating a case based on the value given in these fields I need to autopopulate two other fields.

Account--user entered
Product--user entered
system-user entered
Environment --user entered

We need to autopopulate 
ticket.productbuild =
Ticket.system version=

These values comes from account.
svc-product-build is another object with lookup account .

Need to fetch values of product build and system version from svc product build object with account as a lookup.

It's very challenging. Can anyone help with this autopopulation of fields
Hi,
i have a table inside lightning component..aura iteration items comes from another lightning component..when i add the new record then the table should refresh and display the values..can anyone help me with that..
<div class="slds-m-around_xx-small">
        <div class="slds-align--absolute-left">
        <h1 class="slds-text-heading--small">Below are the 5 most recent work time entries</h1>
            <br/>
        </div>
                </div>
                             
                            <table class="slds-table slds-table_bordered slds-table_cell-buffer">
        <thead>
            <tr class="slds-text-title--caps">
                
                <th scope="col"><div class="slds-truncate" title="Id">S.No</div></th>
               
                <th scope="col"><div class="slds-truncate" title="Work Date">Work Date</div></th>
                <th scope="col"><div class="slds-truncate" title="User">User</div></th>
                <th scope="col"><div class="slds-truncate" title="Minutes">Minutes</div></th>
                <th scope="col"><div class="slds-truncate" title="After Hours">After Hours</div></th>
                <th scope="col"><div class="slds-truncate" title="Reason">Reason</div></th>
                
                
            </tr>
        </thead>          
        <tbody>
    
               <aura:iteration items="{!v.timeList}" var="time" indexVar="sNo"  >
              
                       
             
                   <c:Inlinechildtime single="{!time}"  sNo="{!sNo + 1}"/>
                   
            </aura:iteration>
            </tbody>
            </table>
                            <br/>
                            <br/>
                            <center>
                            <div class="slds-m-around_xx-small">
        <div class="slds-align--absolute-Center">
        <h1 class="slds-text-heading--small">Do you need to add any additional work time?</h1>
            <br/>
            <br>
            </br>
            <br>
            </br>
        </div>
                </div>
                            
                    <button class="slds-button slds-button_success" type ="submit" onclick="{!c.actionhandler2}"  >Yes</button>
                                

                            <button class="slds-button slds-button_destructive" onclick="{!c.handleNext1}">No</button>
                                <br/>
                                <br/>
                                <br/>
                                <br/><br/>
                                <br/>
                                <br/><br/><br/><br/>
                           
            <aura:if isTrue="{!v.seeu}">
 <div role="dialog" aura:id="Modalbox" class="slds-modal slds-fade-in-open ">
               <div class="slds-modal__container">
                   
                   <div class="slds-m-around--xx-large">
                       
        <lightning:card title="Work Time" iconName="custom:custom86" class="slds-p-around_medium">
            <br/>
            <lightning:recordEditForm aura:id="leadCreateForm2"  objectApiName="SVC_Work_Time__c">
                <lightning:messages />
                 
                <lightning:inputField fieldName="Ticket__c" value="{!v.recordId}"></lightning:inputField>
                        <lightning:inputField aura:id="lookup" fieldName="Work_Date__c"></lightning:inputField>
                   
                   
                        <lightning:inputField aura:id="lookup" fieldName="User__c"></lightning:inputField>
               
               
                        <lightning:inputField aura:id="lookup" fieldName="Minutes__c"></lightning:inputField>
                  
                   
                        <lightning:inputField aura:id="lookup" fieldName="After_Hours__c"></lightning:inputField>
                
                          
                        <lightning:inputField aura:id="lookup" fieldName="Reason__c"></lightning:inputField>
                  <br/><br/><br/>
                <center>
                 
                <lightning:button type="submit" label="Save" variant="brand" onclick="{!c.handleOnSubmit}"/>
                    <lightning:button type="submit" label="Save and New"  variant="brand" onclick="{!c.handleOnSubmit2}"/> 
                <lightning:button  label="Close" onclick="{!c.closemodal}" variant="brand"/>
                </center>
            </lightning:recordEditForm>
        </lightning:card>
    </div>
                </div>
            </div>
            <div class="slds-backdrop slds-backdrop--open" aura:id="Modalbackdrop"> 
             </div>
         
          </aura:if>    

how to refresh this table..

thanks 
 
Hi i have progressive steps..based on the condition step 3 should display otherwise it should be skipped..

Condition is if Information_Request_Type__c field is 
BIS License Request,information,online support and some more values the step 3 should be skipped ..
Can anyone help me to write aura if condition with too many values.

<aura:if isTrue="{!v.ticket.Billable__c}">
                           
                           <lightning:progressStep label="Open Tasks" value="1" onclick="{!c.selectStep1}"/>
                                                       
                          
                            <lightning:progressStep label="Billing Details" value="2" onclick="{!c.selectStep2}"/>
                               
                           
                            <lightning:progressStep label="Work Time" value="3" onclick="{!c.selectStep3}"/>
                            
                            <lightning:progressStep label="Ticket Details" value="4" onclick="{!c.selectStep4}"/>
                            <lightning:progressStep label="KB/Problem" value="5" onclick="{!c.selectStep5}"/>
                               
                         <aura:set attribute="else">
                              
                            <lightning:progressStep label="Open Tasks" value="1" onclick="{!c.selectStep1}"/>
                  
                            <lightning:progressStep label="Work Time" value="3" onclick="{!c.selectStep3}"/>
                            
                            <lightning:progressStep label="Ticket Details" value="4" onclick="{!c.selectStep4}"/>
                            <lightning:progressStep label="KB/Problem" value="5" onclick="{!c.selectStep5}"/>
                              </aura:set>
                            </aura:if>
Hi,
while creating a new case for recortype incident and service request
two fields system and product are mandatory .so when the user gives the value for system and product other two fields product build and system version should get autopopulated.Can anyone share code or workaround for it.all are lookup fields in case object.User-added image
Hi,
  <lightning:recordEditForm recordId ="{!v.recordId}" objectApiName = "Case" aura:id="leadCreateForm1" onload="{!c.Onload}" >
        <lightning:messages />
          
 
        <lightning:inputField fieldName="Solution__c" required ="true"/>
           
            <lightning:inputField fieldName="Product_Build__c" required ="true" />
             <lightning:inputField fieldName="System_Version__c" required ="true" />
           
            <lightning:inputField fieldName="Feature_Function__c" required ="true" />
Here feature is a lookup field in case..I need to change it to picklist based on the value selected in product field in case page..i used custom lookup component but there is a condition that the picklist values depends on value in product field .
    public List<SelectOption> getFeatureFunction(){
        List<SelectOption> FeatureFunction = new List<SelectOption>();
        if(selProductId!=null){

            //Feature Functions related to Selected Product
            for(SVC_Feature_Function__c FF : [Select Id, Name From SVC_Feature_Function__c WHERE Product__c=:selProductId order by Name asc])
                FeatureFunction.add(new SelectOption(FF.Id,FF.Name));
        }
        return FeatureFunction;
    }

.Can anyone help me with this code?

Thanks
 
Hi,

I created a search component which displays knowledge articles in table format.
User-added image
here when i click attach button it should attach to the related list in case object (same like knowledge component)
User-added image


The related list URL is /lightning/r/5001O00001mIcsLQAS/related/CaseArticles/view

My output should look like
User-added image
Hi,

My requirement is to search for knowledge article and attach the searched article to the case object using  aura lightning component.Can anyone help me with this?

Thanks,
Hi I have a requirement of displaying the table with list of tasks related to the case ID in a modal and also I need to add checkbox to that table so that once it is checked the status of that task should change to closed.can anyone help me with this coding

Thanks
Hi 

I have a requirement .clicking a button has two conditions .working in lightning component.if one checkbox is true and other checkbox is false it displays popup message and for other conditions it moves to other lightning component in modal and also I need to pass same ID so that lightning component page displays the record based on id.

Can anyone help me with this coding?

Thanks,

Vanitha Mani 
Hi everyone,

I have a requirement of not showing status field in chatter feed but for case object status is the default field.i tried to uncheck in feed tracking but still it exists.can anyone help me out in removing status from chatter feed.

Thanks
Hi can anyone solve view state error in my controller and VF page .

Controller: public with sharing class SVC_CR_CloneCRPackage_Ctl { private final static List<String> EXCLUDED_STATUSES = new List<String>{'Closed', 'Cancelled'}; public Boolean isCompleted {get; set;} public Boolean getRelatedAccountOnly {get; set;} public SelectableChangeRequest[] changeRequests {get; set;} private SVC_CP_QueryBuilder changeRequestsQB; private SVC_CR_Package__c crPackage; public SVC_CR_CloneCRPackage_Ctl() { getRelatedAccountOnly = true; isCompleted = false; crPackage = getCrPackage(); changeRequests = getChangeRequests(); } /** * Clones cr package to selected change requests */ public PageReference clonePackageToChangeRequests(){ Savepoint sp = Database.setSavepoint(); try { Set<ID> crIds = new Set<ID>(); for (SelectableChangeRequest record : changeRequests) { if (record.selected) { crIds.add(record.obj.Id); } } if (crIds.size() > 0) { return handleSuccess(SVC_CR_Package_Service.clonePackage(crIds, crPackage.Id)); } } catch (Exception e) { Database.rollback(sp); ApexPages.addMessage(SVC_ErrorHandler.logAndConvertToApexMessage(e)); } return null; } /** * Redirects to new package if there is one, * Displays list of new packages if there are many */ private PageReference handleSuccess(SVC_CR_Package__c[] newPackages) { if (newPackages.size() == 1) { return redirect(newPackages[0].Id); } showSuccess(newPackages); return null; } /** * Displays success message with list of new packages */ private void showSuccess(SVC_CR_Package__c[] newPackages) { for (SVC_CR_Package__c record : newPackages) { String message = Label.SVC_CR_ClonedPackages.replace('{0}', '/' + record.Id) .replace('{1}', record.Name); ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.INFO, message)); } ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.CONFIRM, Label.SVC_CR_ClonedPackageSuccess)); isCompleted = true; } /** * Redirects back to Opportunity record */ public PageReference cancel() { return redirect(crPackage.Id); } /** * Displays only change requests that has Account related to Opportunity */ public void withRelatedAccount() { getRelatedAccountOnly = true; changeRequests = getChangeRequests(); } /** * Displays all change requests */ public void withAllAccounts() { getRelatedAccountOnly = false; changeRequests = getChangeRequests(); } /** * Redirects to cr package page */ private PageReference redirect(ID recordId) { PageReference retURL = new PageReference('/' + recordId); retURL.setRedirect(true); return retURL; } /** * Queries cr package record */ private SVC_CR_Package__c getCrPackage() { return (SVC_CR_Package__c) SVC_CP_QueryBuilder.getInstance(SVC_CR_Package__c.SObjectType) .withAllFields() .withField('Change_Request__r.Opportunity__c') .withField('Change_Request__r.Account__r.Name') .withField('Change_Request__r.Account__r.Systems_Parent__c') .andWhereEq(SVC_CR_Package__c.Id, ApexPages.currentPage().getParameters().get('packageId')) .queryOne(); } /** * Queries change requests */ private SelectableChangeRequest[] getChangeRequests() { SVC_CP_QueryBuilder changeRequestsQB = SVC_CP_QueryBuilder.getInstance(SVC_Change_Request__c.SObjectType) .withAllFields() .withFields(new String[]{ 'Account__c', 'Account__r.Name', 'Account__r.Systems_Parent__c', 'Opportunity__c', 'Opportunity__r.Name', 'Change_Owner__c', 'Change_Owner__r.Name' }) .andWhereEq(SVC_Change_Request__c.RecordTypeId, SVC_CR_ChangeRequestService.getInstance().getProjectRecordTypeId()) // .andWhereNotIn( // SVC_Change_Request__c.Id, // SVC_CP_QueryBuilder.getInstance(SVC_CR_Package__c.SObjectType) // .withField(SVC_CR_Package__c.Change_Request__c) // .andWhereNotIn('Change_Request__r.Status__c', EXCLUDED_STATUSES) // ) .andWhereNotIn(SVC_Change_Request__c.Status__c, EXCLUDED_STATUSES); if (getRelatedAccountOnly) { Set<ID> relatedAccountIds = new Set<ID>{crPackage.Change_Request__r.Account__c}; if (crPackage.Change_Request__r.Account__r.Systems_Parent__c != null) { relatedAccountIds.add(crPackage.Change_Request__r.Account__r.Systems_Parent__c); } changeRequestsQB.andWhereIn('Account__r.Systems_Parent__c', relatedAccountIds); } SVC_Change_Request__c[] changeRequests = (SVC_Change_Request__c[]) changeRequestsQB.queryList(); SelectableChangeRequest[] crs = new SelectableChangeRequest[]{}; for (SVC_Change_Request__c cr : changeRequests) { crs.add(new SelectableChangeRequest(cr)); } return crs; } public class SelectableChangeRequest { public Boolean selected {get; set;} public SVC_Change_Request__c obj {get; set;} public SelectableChangeRequest(SVC_Change_Request__c obj) { this.obj = obj; this.selected = false; } } } Visual force page <apex:page controller="SVC_CR_CloneCRPackage_Ctl"> <apex:stylesheet value="{!URLFOR($Resource.BugPagination, 'DataTable/CSS/jquery.dataTables.min.css')}"/> <apex:stylesheet value="{!URLFOR($Resource.BugPagination, 'DataTable/ExternalCSS/ExternalCSS.css')}"/> <style> .message .messageText a { margin: 0; font-size: 100%; } </style> <script type="text/javascript" language="javascript" src="{!URLFOR($Resource.BugPagination, 'DataTable/JS/jquery-1.10.2.min.js')}"></script> <script type="text/javascript" language="javascript" src="{!URLFOR($Resource.BugPagination, 'DataTable/JS/jquery.dataTables.min.js')}"></script> <script type="text/javascript" language="javascript"> var j$ = jQuery.noConflict(); j$(document).ready(function() { initTable(); }); var initTable = function() { j$('table.dataTable').dataTable({ "bPaginate" : false, "bLengthChange" : false, "bFilter" : true, "bSort" : true, "bInfo" : true, "bAutoWidth" : false, "scrollY": "500px", "columnDefs": [ { "orderable": false, "targets": 0 }, ] }); }; </script> <apex:form > <apex:pageblock id="pbId"> <apex:pageMessages escape="false" id="messages"/> <apex:pageBlockButtons id="PgButtons"> <apex:commandButton value="Back" action="{!cancel}" immediate="true"/> <apex:commandButton value="Clone Package To Selected CRs" action="{!clonePackageToChangeRequests}" reRender="pbId" status="fetchStatus" rendered="{!NOT(isCompleted)}"/> </apex:pageBlockButtons> <apex:outputPanel > <apex:actionStatus id="fetchStatus"> <apex:facet name="start"> <img src="/img/loading.gif"/> </apex:facet> </apex:actionStatus> </apex:outputPanel> <apex:pageBlockSection id="pageSection" columns="1" rendered="{!NOT(isCompleted)}"> <apex:outputPanel id="accountFilters"> <apex:commandLink action="{!withRelatedAccount}" value="Show related Account" id="relatedAccountLink" rendered="{!!getRelatedAccountOnly}" reRender="pageSection" status="fetchStatus" onComplete="initTable();"/> <apex:commandLink action="{!withAllAccounts}" value="Show all Accounts" id="allAccountsLink" rendered="{!getRelatedAccountOnly}" reRender="pageSection" status="fetchStatus" onComplete="initTable();"/> </apex:outputPanel> <apex:pageBlockTable id="crTable" value="{!changeRequests}" var="item" styleClass="dataTable"> <apex:column id="row"> <apex:inputCheckbox id="selectBox" value="{!item.selected}"/> </apex:column> <apex:column > <apex:facet name="header">Change Request</apex:facet> <apex:outputLink value="/{!item.obj.Id}">{!item.obj.Name}</apex:outputLink> </apex:column> <apex:repeat value="{!$ObjectType.SVC_Change_Request__c.FieldSets.PackageCloneListView}" var="f"> <apex:column value="{!item.obj[f]}"/> </apex:repeat> </apex:pageBlockTable> </apex:pageBlockSection> </apex:pageblock> </apex:form> </apex:page>