• Shreyas Dhond 16
  • NEWBIE
  • 45 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 9
    Replies
Hi all,

I am trying to setup my build.xml to reference the ant-salesforce.jar from my project checkout. The directory structure is similar to this:
Project Dir
>src
>ant-salesforce.jar
>build.xml

I am trying to reference the ant-salesforce.jar from the root directory of the project in my build.xml as shown below:
<project name="Test" default="test" basedir=".">

	<property environment="env"/>

	<taskdef resource="com/salesforce/antlib.xml">
      <classpath>
          <pathelement location="./ant-salesforce.jar" />
      </classpath>
  </taskdef>

	<target name="retrieve">
		<sf:retrieve username="${SRC_USERNAME}" password="${SRC_PASSWD}" serverurl="${SRC_URL}" retrieveTarget="src" unpackaged="src/package.xml"/>
	</target>

	<target name="deployValidate">
		<sf:deploy username="${DEST_USERNAME}" password="${DEST_PASSWD}" serverurl="${DEST_URL}" deployRoot="src" rollbackOnError="true" checkonly="true"/>
	</target>

	<target name="deploy">
		<sf:deploy username="${DEST_USERNAME}" password="${DEST_PASSWD}"    serverurl="${DEST_URL}" deployRoot="src" rollbackOnError="true" />
	</target>
</project>

However, it keeps giving me the following error:
build.xml:12: The prefix "sf" for element "sf:retrieve" is not bound.

Am I missing something when including the reference to the ant-salesforce.jar?

Any help would be appreciated.

Thanks
I am getting the following error message while creating an account (Person Account/Household):

"FinServ.AccountTrigger: execution of BeforeInsert caused by: FinServ.MoiExceptionWrapper.ValidationException: Your account record type is missing, a duplicate, or invalid. Ask your admin to check the individual record type configurations in Setup. (FinServ)"

I think it has something to do with my account record type settings. I tried checking in setup for the same but couldn't find anything. Also under Wealth Management Set up> Groups > Record types - I didn't find any records. Is this ok?
 
*Note - The org set up is not part of any firm or entity. Its set up for training purposes as suggested in Trailhead modules.
 
Any help to resolve this would be great. Thanks in advance.

Hi,

I am trying to update orderTrigger on challenge 2, and  I am getting below error:
User-added image

Please find my trigger and helper class below. Any help would be highly appreciated.

orderTrigger:

/**
 * @name orderTrigger
 * @description
**/
trigger orderTrigger on Order (after update) {
    public Set<Id> orderIds = new Set<Id>();
    if(Trigger.new != null){
    	orderIds = OrderHelper.AfterUpdate(Trigger.new, Trigger.old);    
    }
    
    OrderHelper.RollUpOrderItems(orderIds);
    
}

OrderHelper:
public with sharing class OrderHelper {

    /**
     * @name AfterUpdate
     * @description 
     * @param List<Order> newList
     * @param List<Order> oldList
     * @return void
    **/
    public static Set<Id> AfterUpdate(List<Order> newList, List<Order> oldList){
        Set<Id> orderIds = new Set<Id>();
        for ( Integer i=0; i<newList.size(); i++ ){
            if ( newList[i].Status == 'Activate' && oldList[i].Status == 'Draft' ){
                orderIds.add(newList[i].Id);
            }
        }
        return orderIds;
    }

    /**
     * @name RollUpOrderItems
     * @description Given a set of Activated Order ids, query the child Order Items and related Products to calculate Inventory levels
     * @param Set<Id> activatedOrderIds
     * @return void
    **/
    public static void RollUpOrderItems(Set<Id> activatedOrderIds){
        Map<Id, Product2> productMap;
        Set<Id> product2Ids = new Set<Id>();
        List<OrderItem> orderItems = [SELECT Id, Quantity, Product2Id FROM OrderItem WHERE OrderId IN:activatedOrderIds];
        for(OrderItem item :orderItems){
            product2Ids.add(item.Product2Id);
        }
        productMap = new Map<Id, Product2>([SELECT Id, Quantity_Ordered__c FROM Product2 WHERE Id IN :product2Ids]);
        for(OrderItem item :orderItems) {
            if(productMap.containsKey(item.Product2Id)) {
                productMap.get(item.product2Id).Quantity_Ordered__c -= item.Quantity;
            }
        }
        update productMap.values();
    }

}
Hi,
I am trying to complete the challenge Lightning Data Service Basics - Manipulate Records with force:recordData and I am getting the followling error:
Challenge Not yet complete... here's what's wrong:
Could not find either the 'accEdit' component, 'accDisplay' component or both components in the Account Record Page.
This is strange because the 2 components are indeed on the page:
User-added image
Could please assist ?
Thanks for your help.
 
Hi everyone!,

I am stuck on the suerbadge challenge:
Data Integration Specialist #3 Synchronize Salesforce opportunity data with Square Peg's PMS external system

This is my code:
 
public class ProjectCalloutService {
    public static Id opportunityId;
    
    @InvocableMethod
    public static void postOpportunityToPMS(List<Id> opportunityIds){
        opportunityId=opportunityIds.get(0);
        Opportunity opp=[Select Id,Name, closeDate,amount,Account.Name FROM Opportunity Where Id =: opportunityId];
        ID jobID = System.enqueueJob(new QueueablePMSCall(opp));
    }    
    
    public class QueueablePMSCall implements Queueable,Database.AllowsCallouts
    {
        private String jsonOpp;
        private Opportunity opportunityObject;
        public QueueablePMSCall(Opportunity opp)
        {
            opportunityObject=opp;
            JSONGenerator gen = JSON.createGenerator(true);
            gen.writeStartObject();
            gen.writeStringField('opportunityId', opp.Id);
            gen.writeStringField('opportunityName', opp.Name);
            gen.writeStringField('accountName', opp.account.Name);
            gen.writeDateField('closeDate', opp.closeDate);
            gen.writeNumberField('amount', opp.amount);
            
            gen.writeEndObject();            
            
            jsonOpp= gen.getAsString();
            System.debug('jsonOpp: ' + jsonOpp);
            
        }
        public void execute(QueueableContext context) {
            
            ServiceTokens__c token= ServiceTokens__c.getValues('ProjectServiceToken');
            System.debug(token.Token__c);
            
            // create an HTTPrequest object    
            HttpRequest req = new HttpRequest();
            req.setMethod('POST');
            req.setEndpoint('callout:ProjectService/'+ token.Token__c);
            req.setHeader('Content-Type', 'application/json');
            req.setBody(jsonOpp);    
            
            // create a new HTTP object
            Http http = new Http();
            HTTPResponse res = http.send(req);
            if (res.getStatusCode() != 201) {
                System.debug('Error from ' + req.getEndpoint() + ' : ' +
                             res.getStatusCode() + ' ' + res.getStatus());
                
                Opportunity opportunity1=[Select Id, StageName FROM Opportunity Where Id =: opportunityObject.Id];
                opportunity1.StageName='Resubmit Project';
                update opportunity1;
                
            }
            else {
                Opportunity opportunity2=[Select Id, StageName FROM Opportunity Where Id =: opportunityObject.Id];
                opportunity2.StageName='Submitted Project';
                update opportunity2;
            }      
        }
        
    } 
}

Thanks
I am getting the following error:

The 'Sales Manager' dashboard does not have the correct headers and titles for the chart components.

Here is the screenshot of my dashboard

Dashboard
I am building a continuous delivery pipline with ant migration tool and encounted one issue. where do I put ant-salesforce.jar? I can't put it in apache-ant lib folder on host because host created on demand. I was hoping I can specify its locatoin in build.xml file. I took sample build.xml file to try:
build.xml:
    <taskdef resource="com/salesforce/antlib.xml" uri="antlib:com.salesforce">
        <classpath>
            <pathelement location="../ant-salesforce.jar" />
        </classpath>
    </taskdef>

It doesn't work when running ant tool. it complanins about ant-salesforce.jar is not a JAR.
Can someone suggest a solution?
Thanks!
Lin 

I'm trying to make batches from a CSV file written using CSVWriter of opencsv as:
CSVWriter writer = new CSVWriter(new FileWriter(filePath+createFileName), ',', CSVWriter.DEFAULT_QUOTE_CHARACTER);

And BufferedReader to read the written file. The Csv file is written and I think read operation also goes well. So, far its working good. But when I chose particular data to be written to Csv using the same operations, creation of batches comes under error out of it.
An Exception is coming stating "Failed to parse CSV. Found unescaped quote. A value with quote should be within a quote" which is making the Application to not behave in a manner expected.

After going through this error it seems there's some ""(double quote) or "(double quote) symbol present in the data. (I 've the data in form of "asdf","1.0","",,"def").
As far as my understanding I tried to apply Regex to find double quotes but couldn't find any, as after examining the file it doesn't contain the repeated double quotes. The link I followed is:http://stackoverflow.com/questions/3180842/regular-expression-to-find-and-replace-unescaped-non-successive-double-quotes-in

Thereafter in the code, I'm making use of: File tmpFile = File.createTempFile("bulkAPIInsert", ".csv"); to hold the data in a temporary file and then deleting it.

After replacing the above code with the following I somehow handled the coming exception but it futher lead to another one stating "Failed to parse CSV. EOF reached before closing an opened quote".
File tmpFile = new File("bulkAPIInsert.csv");

I don't think the above workaround should be followed as it would be performance issues with the application.

By going through the CSVReader class I found a custom exception defined stating exactly the same Exception as I got. But I think it comes when a double quote is found within some double qoute (the cell value of CSV File). I referred the link as: https://github.com/mulesoft/salesforce-connector/blob/master/src/main/java/com/sforce/async/CSVReader.java

Can anybody suggest me where I'm doing wrong or any workaround for this Problem?

I'm sharing you the code snippet as:
Method1 then Method2 is called.

 

Method1: private List<BatchInfo> createBatchesFromCSVFile(RestConnection connection,
			JobInfo jobInfo, String csvFileName) throws Exception {
		List<BatchInfo> batchInfos = new ArrayList<BatchInfo>();
		BufferedReader rdr = new BufferedReader(new InputStreamReader(
				new FileInputStream(csvFileName)));

		// read the CSV header row
		String hdr = rdr.readLine();
		byte[] headerBytes = (hdr + "\n").getBytes("UTF-8");
		int headerBytesLength = headerBytes.length;
//      I was making use of the following code which I replaced with the next line of code.
//		File tmpFile = File.createTempFile("bulkAPIInsert", ".csv");
		File tmpFile = new File("bulkAPIInsert.csv");
		// Split the CSV file into multiple batches
		try {
			FileOutputStream tmpOut = new FileOutputStream(tmpFile);
			int maxBytesPerBatch = 10000000; // 10 million bytes per batch
			int maxRowsPerBatch = 10000; // 10 thousand rows per batch
			int currentBytes = 0;
			int currentLines = 0;
			String nextLine;

			while ((nextLine = rdr.readLine()) != null) {
				byte[] bytes = (nextLine + "\n").getBytes("UTF-8"); //TODO
				if (currentBytes + bytes.length > maxBytesPerBatch
						|| currentLines > maxRowsPerBatch) {
					createBatch(tmpOut, tmpFile, batchInfos, connection, jobInfo);
					currentBytes = 0;
					currentLines = 0;
				}
				if (currentBytes == 0) {
					tmpOut = new FileOutputStream(tmpFile);
					tmpOut.write(headerBytes);
					currentBytes = headerBytesLength;
					currentLines = 1;
				}
				tmpOut.write(bytes);
				currentBytes += bytes.length;
				currentLines++;
			}

			if (currentLines > 1) {
				createBatch(tmpOut, tmpFile, batchInfos, connection, jobInfo);
			}
		} finally {
			if(!tmpFile.delete())
				tmpFile.deleteOnExit();
			rdr.close();
		}
		return batchInfos;
	}

/**
	 * Wait for a job to complete by polling the Bulk API.
	 */
	Method2: private void awaitCompletion(RestConnection connection, JobInfo job,
			List<BatchInfo> batchInfoList) throws AsyncApiException { 
		try{
			/****
			Some code
			**/
				BatchInfo[] statusList = connection.getBatchInfoList(job.getId())
				.getBatchInfo();
				for (BatchInfo b : statusList) {
					if (b.getState() == BatchStateEnum.Completed) {
						if (incomplete.remove(b.getId())) 
							//Do Something
					}
					else if(b.getState() == BatchStateEnum.Failed){ 

						System.out.println("Reason: "+b.getStateMessage()+".\n  " +
								"Number of Records Processed: "+b.getNumberRecordsProcessed());
						throw (new Exception(""));
					}
				}
			}
		}catch(Exception ex){log.debug(" Exception occurred.");}
	}

 The getStateMessage() method of BatchInfo gives the discussed error messages.

Hello guys,

 

I'm using a wsdl2apex generated class to make callouts to a remote webservice.

I have the below error when i call one of the WS methods.It refers to some failure to parse datetime. i'm not able to spot where the dateTime parsing fails and why it should fail. does apex has a specific date time parsing logic?

Hope someone suggests what this error means.

thanks.

 

Web service callout failed: Failed to deserialize value '0', due to:Unable to parse dateTime