• Sunad Rasane
  • NEWBIE
  • 105 Points
  • Member since 2017

  • Chatter
    Feed
  • 2
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 15
    Replies
Hi there,

Can anybody help me with this code?
I'm trying to generate a list of string values to use as input parameter for another query but when I run it, I keep getting the error System.QueryException: IN operator must be used with an iterable expression.
Refer to the code below:
global class BatchUpdateProductsStagingStatus implements Database.Batchable<sObject>, Database.Stateful {
    
    global Integer varCountParent = 0;
	global Integer varCount = 1;
    global String listParam = '';
    global String listParamfinal ;
    global String query;
	global String queryCondition;
   
    global Database.QueryLocator start(Database.BatchableContext scope) {
        
        List<AggregateResult> ListCatalogItens = new List<AggregateResult>();
        List<AggregateResult> referenceList = [select Parent_Catalog_Item__r.External_Id__c a from Catalog_Item__c where RecordType.Name = 'Format' and Parent_Catalog_Item__r.External_Id__c != null group by Parent_Catalog_Item__r.Id ,Parent_Catalog_Item__r.External_Id__c , Reference_Catalog__c HAVING Count(Id) >1 ORDER BY Parent_Catalog_Item__r.External_Id__c];        
               
        for (AggregateResult c: referenceList) {

            listParam = string.valueOf(c).removeStart('AggregateResult:').removeStart('{a=').removeEnd('}');


            if ( referenceList.size() > 1){				
				if (varCount < referenceList.size()){
					
					listParam = '\''+ String.escapeSingleQuotes(listParam) + '\', ';					
					listParamfinal = listParamfinal + listParam;

					
				}else if (varCount == referenceList.size()){
					listParam = '\''+ String.escapeSingleQuotes(listParam) + '\' ';
					listParamfinal = listParamfinal + listParam;

					}
            }else{
				listParam = '\''+ String.escapeSingleQuotes(listParam) + '\'';
				listParamfinal = listParamfinal + listParam;


			}

			varCount = varCount + 1;
			System.debug(referenceList.size());
            
        }
		
		if(varCount > 1){
			listParamfinal = '('+listParamfinal+')';
			queryCondition = 'and Code__c IN: listParamfinal';
			
		}else queryCondition = 'and Code__c =: listParamfinal';
		
        System.debug('Qtde de registros: '+varCount);
        System.debug(listParamfinal ); 
		System.debug(queryCondition);
               

        query = 'select Id, StatusMessage__c from Products__c where StatusProcess__c = \'Processed\' '+queryCondition;
        
         System.debug(query); 
        return Database.getQueryLocator(query);
    }
    
    global void execute(Database.BatchableContext scope, List<Products__c> lstProducts ){
        
        List<Products__c> Prod2Update = new List<Products__c>();
        
        for (Products__c varProd2Update : lstProducts) {
            
            varProd2Update.StatusMessage__c = 'The staging record was created on Catalog Item as a Stem but it does not have any associated Leaf record with attribute Reference Catalog = TRUE';
            Prod2Update.add(varProd2Update);
            varCountParent = varCountParent + 1;
                                      
        }
        
        update Prod2Update;
            
    }    
    global void finish(Database.BatchableContext scope ){
        System.debug(varCountParent + ' records processed.');
    }    
}
Thanks in advance
 

I am working on the Metadata API to create an Apex trigger dynamically. I have used Apex Wrapper Salesforce Metadata API from Github-  https://github.com/financialforcedev/apex-mdapi.

The error is- 
System.CalloutException: Web service callout failed: WebService returned a SOAP Fault: INVALID_TYPE: This type of object is not available for this organization faultcode=sf:INVALID_TYPE faultactor=

My Extension Controller-

public class OppCreateInstalltionButtonPageCont 
{
    public OppCreateInstalltionButtonPageCont(ApexPages.StandardController stdController)
    {
    }

public String currentRecordId {get;set;}
public Opportunity opp{get;set;}
public Contact con{get;set;}
public Pricebook2 pb{get;set;}
public WorkType wt{get;set;}
public ServiceTerritory st{get;set;}


    public PageReference CreateInstallationWorkOrder()
    {
    currentRecordId  = ApexPages.CurrentPage().getparameters().get('id');
    opp = [Select id,name,Job_Number__c, AccountId, OwnerId from Opportunity where id =: currentRecordId ];
    con = [ Select id, name from contact where accountid =: opp.Accountid];
    pb = [Select id, name from Pricebook2 where Name = 'Standard Price Book'];
    wt = [Select id, name from WorkType where Name = 'Installation'];
    st = [Select id, name from ServiceTerritory where Name = 'All' ];

    WorkOrder wo = new WorkOrder();
    wo.Opportunity__c = opp.id;
    wo.AccountId = opp.AccountId;
    wo.OwnerId = opp.OwnerId;
    wo.contactId = con.id;
    wo.Duration = 8;
    wo.DurationType = 'Hours';
    wo.Priority = 'High';
    wo.Subject= opp.Job_Number__c +' ' + opp.name;
    wo.ServiceTerritoryId = st.Id;
    wo.WorkTypeId = wt.Id;
    wo.Pricebook2Id = pb.Id ;
    insert wo;

    Id workorderId = wo.id;

    List<OpportunityLineItem> oppLineItem =[Select id, name,Quantity,UnitPrice, Product2Id,PricebookEntryId from OpportunityLineItem where OpportunityId =: opp.id];
    List<ProductConsumed> prodconlist = new  List<ProductConsumed> ();
    List<ProductRequired> prodreqlist = new  List<ProductRequired> ();

    for(OpportunityLineItem op : oppLineItem)
    {
        ProductConsumed pc = new ProductConsumed();
        pc.QuantityConsumed = op.Quantity;
        pc.UnitPrice = op.UnitPrice;
        pc.WorkOrderId = workorderId;
        //pc.ProductItemId = op.Product2Id;
        pc.PricebookEntryid = op.PricebookEntryId;
        prodconlist.add(pc);

        ProductRequired pr = new ProductRequired();
        pr.ParentRecordId = workorderId;
        pr.Product2Id = op.Product2Id;
        pr.QuantityRequired = op.Quantity;
        prodreqlist.add(pr);
    }
    insert prodconlist;
    insert prodreqlist;
        
        PageReference page = new PageReference('/'+currentRecordId);
        return page;
    } 
    
    public PageReference CreateServiceWorkOrder()
    {
    currentRecordId  = ApexPages.CurrentPage().getparameters().get('id');
    opp = [Select id,name,Job_Number__c, AccountId, OwnerId from Opportunity where id =: currentRecordId ];
    con = [ Select id, name from contact where accountid =: opp.Accountid];
    pb = [Select id, name from Pricebook2 where Name = 'Standard Price Book'];
    wt = [Select id, name from WorkType where Name = 'Service'];
    st = [Select id, name from ServiceTerritory where Name = 'All' ];

    WorkOrder wo = new WorkOrder();
    wo.Opportunity__c = opp.id;
    wo.AccountId = opp.AccountId;
    wo.OwnerId = opp.OwnerId;
    wo.contactId = con.id;
    wo.Duration = 90;
    wo.DurationType = 'Minutes';
    wo.Priority = 'High';
    wo.Subject= opp.Job_Number__c +' ' + opp.name;
    wo.ServiceTerritoryId = st.Id;
    wo.WorkTypeId = wt.Id;
    wo.Pricebook2Id = pb.Id ;
    insert wo;

    Id workorderId = wo.id;

    List<OpportunityLineItem> oppLineItem =[Select id, name,Quantity,UnitPrice, Product2Id,PricebookEntryId from OpportunityLineItem where OpportunityId =: opp.id];
    List<ProductConsumed> prodconlist = new  List<ProductConsumed> ();
    List<ProductRequired> prodreqlist = new  List<ProductRequired> ();

    for(OpportunityLineItem op : oppLineItem)
    {
        ProductConsumed pc = new ProductConsumed();
        pc.QuantityConsumed = op.Quantity;
        pc.UnitPrice = op.UnitPrice;
        pc.WorkOrderId = workorderId;
        //pc.ProductItemId = op.Product2Id;
        pc.PricebookEntryid = op.PricebookEntryId;
        prodconlist.add(pc);

        ProductRequired pr = new ProductRequired();
        pr.ParentRecordId = workorderId;
        pr.Product2Id = op.Product2Id;
        pr.QuantityRequired = op.Quantity;
        prodreqlist.add(pr);
    }
    insert prodconlist;
    insert prodreqlist;
        
        PageReference page = new PageReference('/'+currentRecordId);
        return page;
    }  
}

I am working on the Metadata API to create an Apex trigger dynamically. I have used Apex Wrapper Salesforce Metadata API from Github-  https://github.com/financialforcedev/apex-mdapi.

The error is- 
System.CalloutException: Web service callout failed: WebService returned a SOAP Fault: INVALID_TYPE: This type of object is not available for this organization faultcode=sf:INVALID_TYPE faultactor=

Hi there,

Can anybody help me with this code?
I'm trying to generate a list of string values to use as input parameter for another query but when I run it, I keep getting the error System.QueryException: IN operator must be used with an iterable expression.
Refer to the code below:
global class BatchUpdateProductsStagingStatus implements Database.Batchable<sObject>, Database.Stateful {
    
    global Integer varCountParent = 0;
	global Integer varCount = 1;
    global String listParam = '';
    global String listParamfinal ;
    global String query;
	global String queryCondition;
   
    global Database.QueryLocator start(Database.BatchableContext scope) {
        
        List<AggregateResult> ListCatalogItens = new List<AggregateResult>();
        List<AggregateResult> referenceList = [select Parent_Catalog_Item__r.External_Id__c a from Catalog_Item__c where RecordType.Name = 'Format' and Parent_Catalog_Item__r.External_Id__c != null group by Parent_Catalog_Item__r.Id ,Parent_Catalog_Item__r.External_Id__c , Reference_Catalog__c HAVING Count(Id) >1 ORDER BY Parent_Catalog_Item__r.External_Id__c];        
               
        for (AggregateResult c: referenceList) {

            listParam = string.valueOf(c).removeStart('AggregateResult:').removeStart('{a=').removeEnd('}');


            if ( referenceList.size() > 1){				
				if (varCount < referenceList.size()){
					
					listParam = '\''+ String.escapeSingleQuotes(listParam) + '\', ';					
					listParamfinal = listParamfinal + listParam;

					
				}else if (varCount == referenceList.size()){
					listParam = '\''+ String.escapeSingleQuotes(listParam) + '\' ';
					listParamfinal = listParamfinal + listParam;

					}
            }else{
				listParam = '\''+ String.escapeSingleQuotes(listParam) + '\'';
				listParamfinal = listParamfinal + listParam;


			}

			varCount = varCount + 1;
			System.debug(referenceList.size());
            
        }
		
		if(varCount > 1){
			listParamfinal = '('+listParamfinal+')';
			queryCondition = 'and Code__c IN: listParamfinal';
			
		}else queryCondition = 'and Code__c =: listParamfinal';
		
        System.debug('Qtde de registros: '+varCount);
        System.debug(listParamfinal ); 
		System.debug(queryCondition);
               

        query = 'select Id, StatusMessage__c from Products__c where StatusProcess__c = \'Processed\' '+queryCondition;
        
         System.debug(query); 
        return Database.getQueryLocator(query);
    }
    
    global void execute(Database.BatchableContext scope, List<Products__c> lstProducts ){
        
        List<Products__c> Prod2Update = new List<Products__c>();
        
        for (Products__c varProd2Update : lstProducts) {
            
            varProd2Update.StatusMessage__c = 'The staging record was created on Catalog Item as a Stem but it does not have any associated Leaf record with attribute Reference Catalog = TRUE';
            Prod2Update.add(varProd2Update);
            varCountParent = varCountParent + 1;
                                      
        }
        
        update Prod2Update;
            
    }    
    global void finish(Database.BatchableContext scope ){
        System.debug(varCountParent + ' records processed.');
    }    
}
Thanks in advance
 
Hello,

what is differentiate Flexipage and record page in lightning page , could you please explain on this.

Thanks & Regards,
Chinna.
I need to restrict editation of a record this way:

Only owner or users above hierarchy can edit the record.

I know that validation rule can obtain NOT(user.id = owner.id), which makes sure that only the owner can edit the record, but how about the users above hierarchy?

I have OWD on public/read, that's. Can't use private OWDs.
Is there any way I can setup the email fields that they are clickable?
I would like to be able to click on the email address and to be redirected to a blank email with the said email address  
I have a lightning component that is called from a button on a layout that is working in the sandbox and I was able to get it successfully deployed to production. I must be missing a setting somewhere. The lightning component builds an email message and sends it. Then it also attaches a visualforce page as a pdf to the custom object. One of my users gets an error when trying to use it in production but not in sandbox. I have given access to the apex classes, objects, fields and visualforce page. I have compared the settings between sandbox and production and still no success. Am I forgetting any other setting?
Can is it possible when we insert CSV lead file using apex class if the insertion in fail the show the which CSV file row fails when inserting a record in Salesforce and store row number in salesforce object
We have a custom code for our Community, but for some reason our designer didn't add any description text to the initial view.  I've seen how to add a description to it, but I'm not sure how to pull the actual line from the Object.
We have:
<td>{!li.Name}
                        <div style="font-size:0.89em;"><b>Description:</b> Yadda yadda yada.</div>
                    </td>
Is it possible to change the Yadda Yadda yada to, say !li.Description from the object?
I am getting the following error when I remove an <apex:outputText value/> from a visual force page

SObject row was retrieved via SOQL without querying the requested field: Preventative_Screening__c.Account__r
An unexpected error has occurred. Your development organization has been notified.

Here is the code before removing the field output
Page:
<apex:page standardController="Preventative_Screening__c" extensions="ContractDocumentExtDIABTest" docType="html-5.0" showHeader="false" sidebar="false" standardStylesheets="false" id="thePage">
    <apex:stylesheet value="{!URLFOR($Resource.slds120,'assets/styles/salesforce-lightning-design-system.css')}"/> 
    <apex:form id="theForm">
    <div>
    </div>
        <div align="Left" id="PatentInfo">
        <apex:outputText value="{!Preventative_Screening__c.Account__r.name}"/><br/>
      
<div style="width:100%;"> 
                <div style="float:left;">
                    <div style="display:{!IF(caseManagerSign != Null,'block','None')} ">
                        <apex:image url="{!URLFOR($Action.Attachment.Download, caseManagerSign.Id)}" rendered="{!caseManagerSign != Null}" width="30%" height="30%"/><br/>
                        <apex:outputLabel value="Signed By: "/>
                        <apex:outputText value="{!Preventative_Screening__c.Last_Modified_for_App__c}"  /><br/>
                        </div>                                                   
                </div>      
            </div>
</div>

</apex:form>

</apex:page>
Extension
/*Description : This class is a controller extension for 'Contract_Template' Page. This class contians the functionality to send email to the Customer and render the PDF for display*/
public Class ContractDocumentExtDIABTest{
    public Preventative_Screening__c contractDocument{get;set;}
    Public Attachment patientSign{get;set;}
    Public Attachment caseManagerSign{get;set;}
    public String chooserender{get;set;}
    Public List<contact> currContactLst;
    public ContractDocumentExtDIABTest(ApexPages.StandardController stdController){
        String parentid;         
        contractDocument= (Preventative_Screening__c) stdController.getRecord();            
        if(contractDocument != Null){
            currContactLst = [SELECT ID FROM Contact WHERE Accountid  = : contractDocument.Account__r.id];
        }        
        List<Attachment> attachmentLst = [SELECT ID,CreatedDate  FROM Attachment WHERE parentId =: contractDocument.id order by CreatedDate asc  ];        
        if(attachmentLst.size() == 1){
            caseManagerSign = attachmentLst[0];  
            } 
        if(attachmentLst.size() == 2){
           caseManagerSign = attachmentLst[0];
           patientSign = attachmentLst[1];                    
        }       
        if(ApexPages.currentPage().getParameters().get('renderAs') != null){
            chooserender = 'print';
        }else{
            chooserender = Null;    
        } 
    }
    /*public void sendEmail(){        
        contractDocument = [SELECT ID,Account__r.email__c,Account__r.id FROM Preventative_Screening__c WHERE ID =:contractDocument.id ];        
        if(contractDocument.Account__r.email__c == Null || currContactLst.size() == 0 ){
            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error,'Please enter the Email address in Account'));                               
        }else{
            System.PageReference currentPage = ApexPages.currentPage();
            Blob pdfData = currentPage.getContentAsPDF();            
            Messaging.EmailFileAttachment emailMessage = new Messaging.EmailFileAttachment();
            emailMessage.setContentType('application/pdf');
            emailMessage.setFileName('Contact.pdf');
            emailMessage.setInline(false);
            if (Test.IsRunningTest()){
                emailMessage.Body = Blob.valueOf('UNIT.TEST');                 
            }else{
              emailMessage.Body = pdfData;     
            }        
            try{
                List<Messaging.SingleEmailMessage> emailMessageLst= new List<Messaging.SingleEmailMessage>();
                Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
                String[] toAddresses = new String[] {contractDocument.Account.email__c};
                mail.setToAddresses(toAddresses);
                EmailTemplate currEmailTemplate = [SELECT ID from EmailTemplate WHERE Name = : Label.Email_Template_Name_for_Contract_Document];
                mail.setTemplateId(currEmailTemplate.id);
                mail.setWhatId(contractDocument.Account__r.id);
                mail.setTargetObjectId(currContactLst[0].id);
                mail.setTreatTargetObjectAsRecipient(true);
                mail.setSaveAsActivity(true);                    
                mail.setFileAttachments(new Messaging.EmailFileAttachment[] { emailMessage});                    
                emailMessageLst.add(mail);             
                Messaging.sendEmail(emailMessageLst);   
            }Catch(Exception ex){
                System.debug('Exception Message'+ex.getmessage());
            } 
            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.CONFIRM,'Email sent successfully'));  
        }    
    }*/
    
}
Photo of VF Page working
User-added image
VF Page after removing apexOutput 
<apex:page standardController="Preventative_Screening__c" extensions="ContractDocumentExtDIABTest" docType="html-5.0" showHeader="false" sidebar="false" standardStylesheets="false" id="thePage">
    <apex:stylesheet value="{!URLFOR($Resource.slds120,'assets/styles/salesforce-lightning-design-system.css')}"/> 
    <apex:form id="theForm">
    <div>
    </div>
        <div align="Left" id="PatentInfo">

      
<div style="width:100%;"> 
                <div style="float:left;">
                    <div style="display:{!IF(caseManagerSign != Null,'block','None')} ">
                        <apex:image url="{!URLFOR($Action.Attachment.Download, caseManagerSign.Id)}" rendered="{!caseManagerSign != Null}" width="30%" height="30%"/><br/>
                        <apex:outputLabel value="Signed By: "/>
                        <apex:outputText value="{!Preventative_Screening__c.Last_Modified_for_App__c}"  /><br/>
                        </div>                                                   
                </div>      
            </div>
</div>

</apex:form>

</apex:page>

Image of error
User-added image


Any ideas on how to successfully remove this Apex outputfield and avoid this error?

 
We need to convert lead via Api. I couldn't find the api so if anyone knows let me know please.
1.I have tried manually to convert lead process like first create account for lead companyname,then use that created account-id create new contact.
2.finally updating those fields via[https://ap16.salesforce.com/services/data/v46.0/sobjects/Lead/{ID}?_HttpMethod=PATCH](ConvertedContactId, ConvertedAccountId, ConvertedDate, IsConverted, ConvertedOpportunityId).
3.For the above request i got below Error message show like this("message": "Unable to create/update fields: ConvertedContactId, ConvertedAccountId, ConvertedDate, IsConverted, ConvertedOpportunityId. Please check the security settings of this field and verify that it is read/write for your profile or permission set.",
        "errorCode": "INVALID_FIELD_FOR_INSERT_UPDATE")
I am trying to deploy, big objects from workbench. 
By Using Examples mentioned in trail head, I cannot do the same in my org. 
I have followed all the proccess, Can Some help me here.. 
Struck on the new trail for the BigObject. Created those Bigobject using workbench. Can see the object on the Org. However, on validating throws up error "Challenge Not yet complete... here's what's wrong: 
Couldn’t find the correct information. Please double check the instructions." bit difficult judge on the problem. I can send the .xml files for verification.
 

what is the difference between salesforce administrator and developer ?

Can somebody please explain it.

  • January 04, 2012
  • Like
  • 0