• nilesh walke
  • NEWBIE
  • 90 Points
  • Member since 2021

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 26
    Questions
  • 30
    Replies
    • Take a custom button and place it on the detail page for account.
    • On click of the button, a Visualforce page should be opened.
    • The page should display the account details in a page block and display the related attachments in page block below it in tabular format.
    • The table showing the attachments should have link to delete an attachment record.
public class test4 {
    private String recordId; 
    public List<contactwrapper> contactList{get;set;}
    public List<ContactWrapper> wconlist {get;set;}
   // public List<contact> selectedContacts {get;set;}
    public List<contactWrapper> contactWrappersToReturn {get;set;}
    public class contactWrapper{
        public contact con { get; set; }
        public boolean isSelected {get; set;}
    }
    public test4(){
       contactList = new List<contactwrapper>();
        if(Test.isRunningTest()){
            Account obj = [SELECT Id, Name FROM Account LIMIT 1];
            recordId = obj.Id;    
        }else{
            recordId = ApexPages.currentPage().getParameters().get('id');
        }
        contactList.addAll(getcontactWrappers());
    }
    public List<contactWrapper> getcontactWrappers() {
          contactWrappersToReturn = new List<contactWrapper>();      
        List<Contact> conlist = [SELECT ID, LastName,phone,Email from Contact WHERE AccountId=:recordId]; 
       for (Contact conn : conlist ) {
           
           ContactWrapper conWrapper = new ContactWrapper();
          
            conWrapper.con = conn ;          
            contactWrappersToReturn.add(conWrapper);
            system.debug('xyz'+ conWrapper);
        }   
        return contactWrappersToReturn;   
    }      
    public PageReference SendMail(){        
        List<Contact> selectedContacts = new List<Contact>();
        System.debug('==>Inside sendEmail() '+ contactWrappersToReturn);
        for(ContactWrapper c: contactWrappersToReturn) {
            if(c.isSelected == true) {
                selectedContacts.add(c.con);
            }
        }
        System.debug('toaddresses==>'+ selectedContacts);
        String []toAddresses = new List<String>();    
        for(Contact con : selectedContacts) {
            toAddresses.add(con.Email);           
        }
        System.debug('toaddresses==>'+toAddresses);
        Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
        mail.setToAddresses(toAddresses);
        mail.setSubject('Account related contacts' );
        mail.setHtmlBody('thanks for contacts');
        Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });   
        return null;       
    } 
    
}



<apex:page controller="test4" showHeader="false" standardStylesheets="false">
    <apex:form > 
        <apex:pageBlock > 
            <apex:pageBlockButtons location="bottom" >
                <apex:CommandButton value="Send Email" action="{!SendMail}" reRender="table" />
            </apex:pageBlockButtons>    
            <apex:stylesheet value="//cdn.datatables.net/1.10.5/css/jquery.dataTables.css"/>
            <apex:includeScript value="//code.jquery.com/jquery-1.10.2.min.js"/>
            <apex:includeScript value="//cdn.datatables.net/1.10.5/js/jquery.dataTables.js"/>
            <div style="width:80%; margin-left:auto; margin-right:auto; margin-top:50px;">
                <table id="table_id" class="display">
                    <thead>
                        <tr>
                            <th> SelectAll<input id="chktrue" type="checkbox" class="selectAll" checked=""/></th>
                            <th>Contact Name</th>
                            <th>phone</th>
                            <th>Email</th>
                        </tr>
                    </thead>
                    <tbody>
                        <apex:repeat value="{!contactList}" var="conlist">
                            <tr>
                                <td><input type="checkbox"  value="{!conlist.isSelected}"  name="chk{!conlist.con.id}"/></td>
                                <td>{!conlist.con.Lastname}</td>
                                <td>{!conlist.con.phone}</td>
                                <td>{!conlist.con.Email}</td>
                            </tr>
                        </apex:repeat>               
                    </tbody>
                </table>
            </div>
            <script>
            $(document).ready( function () {
                $('#table_id').DataTable();
                $('#chktrue').attr('disabled','true');
            } );            
            (function($) {               
                'use strict';               
                $.fn.extend({
                    checkboxes: function(options) {
                        // Default option
                        var defaults = {
                            itemChild: ''
                        };                        
                        var option = $.extend(defaults, options);
                        // Checked value function
                        function checkedValue(element, bool) {
                            if (bool) {
                                return element.each(function() {
                                    $(this).prop('checked', true);
                                });
                            } else {
                                return element.each(function() {
                                    $(this).prop('checked', false);
                                });
                            }
                            $(":checkbox").click(function(){
                                $("#id").text(this.value)
                            })                            
                        }                        
                        // Return checked or unchecked
                        return this.each(function() {
                            var obj = option,
                                $itemAll = $(this),
                                $itemChild = $('input[name^="' + obj.itemChild + '"]');
                                                        // Checked all checkbox before parent checked load page
                            if ($itemAll.is(':checked')) {
                                checkedValue($itemChild, true);
                            }
                      // Checked all or unchecked checkbox when parent checkbox checked or unchecked
                            $itemAll.change(function() {
                                var $self = $(this);
                                
                                if ($self.is(':checked')) {
                                    checkedValue($itemChild, true);
                                } else {
                                    checkedValue($itemChild, false);
                                }
                            });
                   // Checked parent checkbox when all child checkbox checked
                            $itemChild.change(function() {
                                var flag = true;
                                
                                if (!$itemChild.is(':checked')) {
                                    console.log(!$itemChild.is(':checked'));
                                    $itemAll.prop('checked', false);
                                }
                                
                                $itemChild.each(function() {
                                    var $self = $(this);
                                    if (!$self.is(':checked')) {
                                        flag = false;
                                        return;
                                    }
                                });                               
                                $itemAll.prop('checked', flag);
                            });                           
                        });
                    }
                });
            })(jQuery);           
            $(document).ready(function() {
                $('.selectAll').checkboxes({
                    itemChild: 'chk'
                });
            });
            </script>            
        </apex:pageBlock>  
    </apex:form> 
</apex:page>

..

1. Create a button on account to show only contact related to selected account. On button click open VF page
2. Facility to select the multiple contact from list
3. add Send email button on Table so user will send an Email to selected Contacts
4. Pagination should be present for Table

i have create page using visual force pages but not i want that page using jquery is there any developer who can solve my problemUser-added imagei want this datatable using jquery
//controller
public class VPContactController {
    private integer totalRecs = 0;
    private integer OffsetSize = 0;
    private integer LimitSize= 2;
    integer count= 0;
    public string accid ;
    public class cContact {
        public Contact con {get; set;}
        public Boolean selected {get; set;}
        public cContact(Contact c) {
            con = c;
            selected = false;
        }
    }
    public VPContactController  (){
        accid = apexpages.currentpage().getparameters().get('id');
        system.debug('Accid'+accid);
        totalRecs=[select count() from contact];
    }
    public List<cContact> contactList {get; set;}
    public List<cContact> getContacts(){
        if(contactList == null){
            contactList = new List<cContact>();
            for(Contact c : [select Id, Name, Email, Phone from Contact where AccountId=:accid]){
                contactList.add(new cContact(c));
            }
        }
        return contactList;
    }
    public PageReference SendMail() {
        List<Contact> selectedContacts = new List<Contact>();
        for(cContact cCon : getContacts()) {
            if(cCon.selected == true) {
                selectedContacts.add(cCon.con);
            }
        }
        for(Contact con : selectedContacts) {
            string conEmail = con.Email;
            Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
            String[] toAddresses = new String[] {conEmail};
            mail.setToAddresses(toAddresses);
            mail.setSubject('New Mail Created using VF' );
            mail.setHtmlBody('Ala ka re mail');
            Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });    
        }
        return null;
    }      
}
//////
<apex:page controller="VPContactController"  showHeader="false"   >
    <apex:form >
        <apex:pageBlock >         
            <apex:pageBlockButtons location="top"/>               
            <apex:pageBlockTable value="{!contacts}" var="c" id="table">
                <apex:column headerValue="Action" >
                    <apex:inputCheckbox value="{!c.selected}"/>
                </apex:column>
                <apex:column value="{!c.con.Name}" />
                <apex:column value="{!c.con.Email}" />
                <apex:column value="{!c.con.Phone}" />
            </apex:pageBlockTable>
            <apex:pageblockButtons location="top" >
                <apex:commandButton value="Send Email" action="{!SendMail}" rerender="table" />
            </apex:pageblockButtons>
        </apex:pageBlock>
    </apex:form>
</apex:page>
1, Create a button on account to show only contact related to selected account. On button click open VF page
, Facility to select the multiple contact from list
,add Send email button on Table so user will send an Email to selected Contacts
,Pagination should be present for Table
 
public class visualClassQ1 {
    List<EMPLOYEE__c> Emp=[Select Full_Name__c, Branch__c, City__c From EMPLOYEE__c where 
Branch__c='SRNager'];
    Public List<EMPLOYEE__c> getEmp(){
        return Emp;
    }
}
<apex:page controller="visualClassQ1">
    <apex:pageBlock >
    <apex:pageBlockTable value="{!Emp}" var="E">
        <apex:column value="{!E.Full_Name__c }"/>
        <apex:column value="{!E.Branch__c}"/>
        <apex:column value="{!E.City__c}"/>        
        </apex:pageBlockTable>
    </apex:pageBlock>
    
    <apex:form >
    <body >
        <script>
        function call(){
            
            }
        </script>
        <apex:commandButton value="Call" onclick="call()" />
    </body>
</apex:form>          
</apex:page>

want the onclick function logic
global class CreateTaskBatch implements Database.Batchable<sObject>{
global Database.QueryLocator start(Database.BatchableContext bc)
{
return Database.getQueryLocator([select id,ownerid,name from account]);
}
global void execute(Database.BatchableContext bc,List<Account> acclist)
{
list<task> ta=new list<task>();
for(Account a:acclist)
{
task t=new task();
t.OwnerId=a.OwnerId;
t.WhatId=a.Id;
t.Id=a.Id;
t.Description='Created task for Account';
tas.add(t);
}
insert ta;
}
global void finish(Database.BatchableContext bc)
{

}
}
test class for this
 public static void DublicatRec(List<Contact>con){
        Set<String> StEmail=new Set<String>();
        Set<String> StPhone=new Set<String>();
        List<Contact> conList=[select id,name from Contact where Email IN:StEmail OR Phone IN:StPhone];
        
        for(Contact con1 :Con){
            StEmail.add(con1.Email);
            StPhone.add(con1.Phone);
        }
        Map<String,Contact> ConMap=new Map<String,Contact>();
        for(Contact con1 : conList){
            ConMap.put(con1.Email,con1);
            conMap.put(con1.Phone,con1);
        }
        for(Contact con2 :Con)
        {
            if(ConMap.get(con2.Email)!=null){
                con2.addError('Dublicate email');     
            }
            if(ConMap.get(con2.Phone)!=null){
                con2.addError('dublicate phone');
                
            }
        }  
    } 
 public static void ForAge(List<contact> con5){
        for(Contact c:con5){
            Integer days=c.Birthdate.daysBetween(Date.today());
            c.Age__c=Integer.valueOf(days/365);
        }
    }   
 public static void Validation(List<contact> con6){
        //   Opportunity opp= new opportunity();
        for(contact con:con6){
            for(opportunity oppt:[select id, name, amount from opportunity limit 10]){
                if(oppt.Amount<5000 || Oppt.Amount==null){
                    oppt.Amount=5000;
                    oppt.name=oppt.Name +'KING';
                }
                else{
                    oppt.Amount=oppt.Amount+1000;
                    oppt.Name='Dr'+oppt.Name;       
                } 
                Update oppt;
            }
        }
 

trigger CloneARecord on Account (After insert) {  if(cloneHandler.runOnce()){​​​​​​​  
      list<Account>Accounts = new list<Account>();  
      for(Account record: trigger.new){​​​​​​​             Accounts.add(record.clone(false,false,false,false));
        }​​​​​​​
        if(Accounts.size()>0){​​​​​​​
            INSERT Accounts;  
      }​​​​​​​     }​​​​​​​
}​​​​​​​

[05-05 12:45 pm] Nilesh Walke
public class cloneHandler {​​​​​​​​
public static boolean run= true;
public static boolean runOnce(){
​​​​​​​​ if(run){​​​​​​​​ run=false; return true;
}​​​​​​​​
else{​​​​​​​​ return run;
}​​​​​​​​ }​​​​​​​​ }​​​​​​​​

test class for it
public static void ForQnoSIX(List<account> oldAccount, List<account> Ac4){
        List<contact> conList=[select lastname,otherphone,accountid,mobilePhone from contact 
                               where accountid IN: Ac4];
        map<id,string> oldAccidVsPhone= new map<id,string>();
        map<id,string> newAccidVsPhone= new map<id,string>();
        for(account newAcc: Ac4){
            for(account oldAcc: oldAccount){
                if(newAcc.phone!=oldAcc.phone && oldAcc.id==newAcc.id){
                    oldAccidVsPhone.put(oldAcc.id,oldAcc.phone);
                    newAccidVsPhone.put(newAcc.id,newAcc.phone);
                }
            }
        }
        list<contact> updateContactList= new List<contact>();
        for(contact con: conList){
            if(oldAccidVsPhone.containskey(con.accountid)){
                con.otherphone=oldAccidVsPhone.get(con.accountid);
                con.mobilePhone=newAccidVsPhone.get(con.accountid);
                updateContactList.add(con);
            }
        }
        if(updateContactList.size()>0){
            update updateContactList;
        }
    } 


i need test class for it 
thanks for helping me out 
 public static void syncfields(list<contact> con1){
        map<id,contact> contacts=new map<id,contact>();
        list<user> userlist=new list<user>();
        for(contact con:con1)
        {
            if(con.User__c!=null){
                contacts.put(con.User__c,con);//create lookup field inside the contact which look up with user...
            }
        }
        list<user> users=[SELECT mobilePhone,fax,phone from user where id IN:contacts.KeySet()];
        for(user uc:users)
        { 
            if(contacts.get(uc.id).phone!=null){
                uc.phone=contacts.get(uc.id).phone;
            }
            if(contacts.get(uc.id).Fax!=null){
                uc.fax= contacts.get(uc.id).Fax  ;
            }
            if(contacts.get(uc.id).MobilePhone!=null){
                uc.mobilePhone= contacts.get(uc.id).MobilePhone;
            }
            userlist.add(uc);
        }
        if(userlist.size()>0){
            update userlist;
        }   
    }
Here my code  i want code in minimum lines 


public class Demo3 implements Database.Batchable<SObject> {
    public Database.QueryLocator start(Database.BatchableContext BC){
        return Database.getQueryLocator('Select id, name, phone, (select id, name,phone from contacts)from account');
    }
    public void execute(Database.BatchableContext BC,List<Account> Acclist){
        set<id> AccIds = New set<id>();
        for(Account Acc:Acclist){
            AccIds.add(Acc.id);
        }
        map<Id,Account> Acct = new map<id,Account>(Acclist);
        for(Account AC:Acclist){
        if(Acct.get(AC.id).Contacts.size()>0){
            AC.adderror('ERROR');
        }
        }
    }
    public void finish(Database.BatchableContext BC){
        
    }


 
please if you  are able to write it explain it littel bit in few words we need to write batch apex.
and the secound condition is 
Every morning at 7 AM for account we have to create Task record by using Batch class

 
public class test4 {
    private String recordId; 
    public List<contactwrapper> contactList{get;set;}
    public List<ContactWrapper> wconlist {get;set;}
   // public List<contact> selectedContacts {get;set;}
    public List<contactWrapper> contactWrappersToReturn {get;set;}
    public class contactWrapper{
        public contact con { get; set; }
        public boolean isSelected {get; set;}
    }
    public test4(){
       contactList = new List<contactwrapper>();
        if(Test.isRunningTest()){
            Account obj = [SELECT Id, Name FROM Account LIMIT 1];
            recordId = obj.Id;    
        }else{
            recordId = ApexPages.currentPage().getParameters().get('id');
        }
        contactList.addAll(getcontactWrappers());
    }
    public List<contactWrapper> getcontactWrappers() {
          contactWrappersToReturn = new List<contactWrapper>();      
        List<Contact> conlist = [SELECT ID, LastName,phone,Email from Contact WHERE AccountId=:recordId]; 
       for (Contact conn : conlist ) {
           
           ContactWrapper conWrapper = new ContactWrapper();
          
            conWrapper.con = conn ;          
            contactWrappersToReturn.add(conWrapper);
            system.debug('xyz'+ conWrapper);
        }   
        return contactWrappersToReturn;   
    }      
    public PageReference SendMail(){        
        List<Contact> selectedContacts = new List<Contact>();
        System.debug('==>Inside sendEmail() '+ contactWrappersToReturn);
        for(ContactWrapper c: contactWrappersToReturn) {
            if(c.isSelected == true) {
                selectedContacts.add(c.con);
            }
        }
        System.debug('toaddresses==>'+ selectedContacts);
        String []toAddresses = new List<String>();    
        for(Contact con : selectedContacts) {
            toAddresses.add(con.Email);           
        }
        System.debug('toaddresses==>'+toAddresses);
        Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
        mail.setToAddresses(toAddresses);
        mail.setSubject('Account related contacts' );
        mail.setHtmlBody('thanks for contacts');
        Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });   
        return null;       
    } 
    
}



<apex:page controller="test4" showHeader="false" standardStylesheets="false">
    <apex:form > 
        <apex:pageBlock > 
            <apex:pageBlockButtons location="bottom" >
                <apex:CommandButton value="Send Email" action="{!SendMail}" reRender="table" />
            </apex:pageBlockButtons>    
            <apex:stylesheet value="//cdn.datatables.net/1.10.5/css/jquery.dataTables.css"/>
            <apex:includeScript value="//code.jquery.com/jquery-1.10.2.min.js"/>
            <apex:includeScript value="//cdn.datatables.net/1.10.5/js/jquery.dataTables.js"/>
            <div style="width:80%; margin-left:auto; margin-right:auto; margin-top:50px;">
                <table id="table_id" class="display">
                    <thead>
                        <tr>
                            <th> SelectAll<input id="chktrue" type="checkbox" class="selectAll" checked=""/></th>
                            <th>Contact Name</th>
                            <th>phone</th>
                            <th>Email</th>
                        </tr>
                    </thead>
                    <tbody>
                        <apex:repeat value="{!contactList}" var="conlist">
                            <tr>
                                <td><input type="checkbox"  value="{!conlist.isSelected}"  name="chk{!conlist.con.id}"/></td>
                                <td>{!conlist.con.Lastname}</td>
                                <td>{!conlist.con.phone}</td>
                                <td>{!conlist.con.Email}</td>
                            </tr>
                        </apex:repeat>               
                    </tbody>
                </table>
            </div>
            <script>
            $(document).ready( function () {
                $('#table_id').DataTable();
                $('#chktrue').attr('disabled','true');
            } );            
            (function($) {               
                'use strict';               
                $.fn.extend({
                    checkboxes: function(options) {
                        // Default option
                        var defaults = {
                            itemChild: ''
                        };                        
                        var option = $.extend(defaults, options);
                        // Checked value function
                        function checkedValue(element, bool) {
                            if (bool) {
                                return element.each(function() {
                                    $(this).prop('checked', true);
                                });
                            } else {
                                return element.each(function() {
                                    $(this).prop('checked', false);
                                });
                            }
                            $(":checkbox").click(function(){
                                $("#id").text(this.value)
                            })                            
                        }                        
                        // Return checked or unchecked
                        return this.each(function() {
                            var obj = option,
                                $itemAll = $(this),
                                $itemChild = $('input[name^="' + obj.itemChild + '"]');
                                                        // Checked all checkbox before parent checked load page
                            if ($itemAll.is(':checked')) {
                                checkedValue($itemChild, true);
                            }
                      // Checked all or unchecked checkbox when parent checkbox checked or unchecked
                            $itemAll.change(function() {
                                var $self = $(this);
                                
                                if ($self.is(':checked')) {
                                    checkedValue($itemChild, true);
                                } else {
                                    checkedValue($itemChild, false);
                                }
                            });
                   // Checked parent checkbox when all child checkbox checked
                            $itemChild.change(function() {
                                var flag = true;
                                
                                if (!$itemChild.is(':checked')) {
                                    console.log(!$itemChild.is(':checked'));
                                    $itemAll.prop('checked', false);
                                }
                                
                                $itemChild.each(function() {
                                    var $self = $(this);
                                    if (!$self.is(':checked')) {
                                        flag = false;
                                        return;
                                    }
                                });                               
                                $itemAll.prop('checked', flag);
                            });                           
                        });
                    }
                });
            })(jQuery);           
            $(document).ready(function() {
                $('.selectAll').checkboxes({
                    itemChild: 'chk'
                });
            });
            </script>            
        </apex:pageBlock>  
    </apex:form> 
</apex:page>

..

1. Create a button on account to show only contact related to selected account. On button click open VF page
2. Facility to select the multiple contact from list
3. add Send email button on Table so user will send an Email to selected Contacts
4. Pagination should be present for Table

i have create page using visual force pages but not i want that page using jquery is there any developer who can solve my problemUser-added imagei want this datatable using jquery
//controller
public class VPContactController {
    private integer totalRecs = 0;
    private integer OffsetSize = 0;
    private integer LimitSize= 2;
    integer count= 0;
    public string accid ;
    public class cContact {
        public Contact con {get; set;}
        public Boolean selected {get; set;}
        public cContact(Contact c) {
            con = c;
            selected = false;
        }
    }
    public VPContactController  (){
        accid = apexpages.currentpage().getparameters().get('id');
        system.debug('Accid'+accid);
        totalRecs=[select count() from contact];
    }
    public List<cContact> contactList {get; set;}
    public List<cContact> getContacts(){
        if(contactList == null){
            contactList = new List<cContact>();
            for(Contact c : [select Id, Name, Email, Phone from Contact where AccountId=:accid]){
                contactList.add(new cContact(c));
            }
        }
        return contactList;
    }
    public PageReference SendMail() {
        List<Contact> selectedContacts = new List<Contact>();
        for(cContact cCon : getContacts()) {
            if(cCon.selected == true) {
                selectedContacts.add(cCon.con);
            }
        }
        for(Contact con : selectedContacts) {
            string conEmail = con.Email;
            Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
            String[] toAddresses = new String[] {conEmail};
            mail.setToAddresses(toAddresses);
            mail.setSubject('New Mail Created using VF' );
            mail.setHtmlBody('Ala ka re mail');
            Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });    
        }
        return null;
    }      
}
//////
<apex:page controller="VPContactController"  showHeader="false"   >
    <apex:form >
        <apex:pageBlock >         
            <apex:pageBlockButtons location="top"/>               
            <apex:pageBlockTable value="{!contacts}" var="c" id="table">
                <apex:column headerValue="Action" >
                    <apex:inputCheckbox value="{!c.selected}"/>
                </apex:column>
                <apex:column value="{!c.con.Name}" />
                <apex:column value="{!c.con.Email}" />
                <apex:column value="{!c.con.Phone}" />
            </apex:pageBlockTable>
            <apex:pageblockButtons location="top" >
                <apex:commandButton value="Send Email" action="{!SendMail}" rerender="table" />
            </apex:pageblockButtons>
        </apex:pageBlock>
    </apex:form>
</apex:page>
1, Create a button on account to show only contact related to selected account. On button click open VF page
, Facility to select the multiple contact from list
,add Send email button on Table so user will send an Email to selected Contacts
,Pagination should be present for Table
 
 public static void syncfields(list<contact> con1){
        map<id,contact> contacts=new map<id,contact>();
        list<user> userlist=new list<user>();
        for(contact con:con1)
        {
            if(con.User__c!=null){
                contacts.put(con.User__c,con);//create lookup field inside the contact which look up with user...
            }
        }
        list<user> users=[SELECT mobilePhone,fax,phone from user where id IN:contacts.KeySet()];
        for(user uc:users)
        { 
            if(contacts.get(uc.id).phone!=null){
                uc.phone=contacts.get(uc.id).phone;
            }
            if(contacts.get(uc.id).Fax!=null){
                uc.fax= contacts.get(uc.id).Fax  ;
            }
            if(contacts.get(uc.id).MobilePhone!=null){
                uc.mobilePhone= contacts.get(uc.id).MobilePhone;
            }
            userlist.add(uc);
        }
        if(userlist.size()>0){
            update userlist;
        }   
    }
List<Product2> listOfProducts = [SELECT Id, Name, Description, IsActive, Parent_Product__c, Account__c ,
                                   (SELECT Id, Product2Id, Quantity FROM OrderItem) FROM Product2 
                                  WHERE Account__c = 'XYZ'];

ERROR at Row:2:Column:74
Didn't understand relationship 'OrderItem' in FROM part of query call. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names.
  • May 14, 2021
  • Like
  • 0
Apex Class:
______________

public class AskEDD_ArticleAction {
    @InvocableMethod
    public static List<FlowOutputs> updateArticleTypeForDataCategories(List<FlowInputs> articleType) 
    {
        List<Knowledge__kav> lstArticleType = [SELECT Id, Title, AskEDD_Category__c FROM Knowledge__kav WHERE Id =:articleType[0].recordId AND (PublishStatus = 'draft' OR Approval_Status__c = 'Pending Approval')];

        List<Knowledge__DataCategorySelection> lstDC = [SELECT ParentId, DataCategoryName   FROM Knowledge__DataCategorySelection
                                                            WHERE ParentId =:articleType[0].recordId];
List<FlowOutputs> outputlist = new List<FlowOutputs>();
        
        FlowOutputs output = new FlowOutputs();
        
        Map<Id, String> datacategoryNameMap = new Map<Id, String>();

        for(Knowledge__DataCategorySelection dcObj:lstDC)
        {   
            if(datacategoryNameMap.containsKey(dcObj.ParentId))
            {
                String str =  datacategoryNameMap.get(dcObj.ParentId);
                datacategoryNameMap.put(dcObj.ParentId, str + ',' + dcObj.DataCategoryName);
            }
            else
            {
                datacategoryNameMap.put(dcObj.ParentId, dcObj.DataCategoryName);
            }
        }

        for(Knowledge__kav artObj:lstArticleType)
        {
            if(datacategoryNameMap.containsKey(artObj.Id))
            {
                artObj.AskEDD_Category__c = datacategoryNameMap.get(artObj.Id);
                
                if (String.isEmpty(artObj.AskEDD_Category__c)){
                     output.noCategory = true;
                    outputlist.add(output);
                    return outputlist;
                } 
                else {
                     output.noCategory = false;
                    outputlist.add(output);
                }
         //     output.categoryString  = artObj.AskEDD_Category__c;
            }
        }

     //   update lstArticleType;
        return outputlist;
       }  
    public class FlowInputs {
        @InvocableVariable
        public string recordId;
    }
    public class FlowOutputs {
        @InvocableVariable
        public boolean noCategory;
    }
}
User-added image
How to hide Action in Salesforce for Specific Profile ( Account Team Memeber)?