+ Start a Discussion
Brian KesslerBrian Kessler 
I am presently stuck on Einstein Analytics and Discovery Insights Specialist Superbadge (https://trailhead.salesforce.com/en/content/learn/superbadges/superbadge_analytics_insights_specialist) Challenge #3

The dashboard designer tells me there is an error in my Attrition Cost step
Analytics encountered a problem with this step [Attrition_Cost_1]. 
Input stream not found

My SAQL query is this:
beattieSubscribers = load "Beattie_Subs"; tenuredSubscribers = filter beattieSubscribers by{{row(Tenure_Length_1.selection,[0],["min","max"]).asRange ("Tenure")}}; churnedSubscribers = filter tenuredSubscribers by 'Churn' == "Yes"; attrCost = churnedSubscribers * 950.00;

What am I missing?
Best Answer chosen by Brian Kessler
Brian KesslerBrian Kessler
After much struggle and no help, I finally figured it out:

1. After filtering the beattieSubscribers for Tenure and Churn, I need to group these.
groupedSubscribers = group tenuredSubscribers by all full, churnedSubscribers by all;

and then,

2. I needed to generate the attrition cost for each subscriber in the group, and assign the value using "as" syntax, instead of just equals:
attrCost = foreach groupedSubscribers generate count(churnedSubscribers)*950 as 'attrCost';

rima khanrima khan 
I registered with trailhead.
I’m an SDR looking to expand my Salesforce skill set. Let’s pretend I have none. Particularly looking for the basics around reporting, and any other trails that may be beneficial to spend some time with.
My goal is to have a competent understanding of SF to build my sales as I enter a closing role and the relevant tools in SF that will help me gain an advantage.
Thanks in advance!
Best Answer chosen by rima khan
manasa udupimanasa udupi
Hi Rima,

Below are few trailhead links, hope it helps:)

Hi all,
When custom button in detail page of  custom object is clicked i'm generating the PDF . I want to send the generated PDF as email. Can  we do this...?
Can anyone help me over here.

Thanks in advance.
Best Answer chosen by Hanuman
Amit Singh 1Amit Singh 1

Use below code.
-- JavaScript --
var a = sforce.apex.execute("SendEmail","emailPdf",{localId:"{!Application__c.Id}"});

-- Apex Class Method --
public void SendEmail(Id localId){
 Application__c inv = [Select Id, name From Application__c Where Id=:localId];
 PageReference pdf = Page.PDFpage;// Replace PdfOfInvoice with your Page which render as PDF.
 pdf.getParameters().put('id', localId);
// Blob b = pdf.getContentAsPDF();
 Blob b;
 if (Test.IsRunningTest()){b=Blob.valueOf('UNIT.TEST');}else{b = pdf.getContentAsPDF();}
 // Create Attachment Object to attach with Email
 Messaging.EmailFileAttachment efa = new Messaging.EmailFileAttachment();
 // Define the email
 Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
 // Sets the paramaters of the email
 email.setSubject('PDF of Invoice - '+inv.Name);
 email.setToAddresses( new List<String>{inv.Email__c} );
 //email.setbccAddresses( new List<String>{'admin@gmail.com'} );
 email.sethtmlBody('Hi '+inv.Name+',<br/><br/> '
                        +'Please find the attached Invoice.'
 email.setFileAttachments(new Messaging.EmailFileAttachment[] {efa});

      Messaging.SendEmailResult [] result = Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email});
 }catch(System.Exception e){
Let me know if this helps :)

Amit Singh

Arnaud LageirseArnaud Lageirse 
I need to make a validation rule on salutation and gender. 
The rule should be like this: 
If the salutation is Dr. or Prof. then a gender (Male or Female) must be filled in. 

I've already tried some validation rules but non of them worked. 
Could someone help me with it ? 

Thank you.
Best Answer chosen by Arnaud Lageirse
Maharajan CMaharajan C
Hi Arnaud,

Try the below Validation Rule,

OR( ISPICKVAL(Salutation, "Dr.") , 
ISPICKVAL(Salutation, "Prof.")), 
ISBLANK(TEXT(Gender__c)) )

Hi All,

I have created a new Lookup field on standard Prdoduct object which points to one of my custom objects. Field has been created successfully but when I'm trying to set  a value by clicking the magnifying glass the popup doesn't show any records of my Custom object. 
As suggested in some other posts I checked for Search settings in Setup > Customize > Search > Search Settings. Custom objects has been enabled for enhance search at there. Can anyone help me to figure out what is going on please?

Best Answer chosen by madhu_ra

Generally, look up fields picks and displays recently viewed records and that is the reason it won't display list of parent records. you can do following things:
1. Try searching with any keyword , it should display records with keywords.
2. if above doesnot works, check for filters enabled on lookup field. it conflicts sometimes.
Andrew GAndrew G 
I'm doing a trigger that is triggered from the Assigned Resource.  The trigger works in the UI, however, I'm having an issue with the Test Code.

I receive an error:
FIELD_CUSTOM_VALIDATION_EXCEPTION, Cannot change status from New to Scheduled: []

Now, if i do the same from the UI, there is no error regarding the status change.  The status change is allowed in the FSL administration.  I can assign using the dispatcher console - all good.  And I can mimic the process i'm using in the test code in the UI (editing the SA directly) with out error.  
Wondering if any one has seen this error before?
Code is included below:
@isTest static void test_AssignedResource_Insert() {
		List<AssignedResource> toInsert = new List<AssignedResource>();

		//retrieve a service resource
		List<ServiceResource> listSR = new List<ServiceResource>([SELECT Id, Name FROM ServiceResource WHERE Name = 'Technician One']);
		ServiceResource sr1 = listSR[0];

		// retrieve the Service Appointment created by test data
		List<WorkOrder> workOrders = new List<WorkOrder>([SELECT Id FROM WorkOrder WHERE Subject ='Test Subject1']);
		List<Id> woIds = new List<Id>();
		for (WorkOrder wo : workOrders ) {
		if (woIds.size() > 0 ) {
			List<ServiceAppointment> appts = new List<ServiceAppointment> ();
			appts = [SELECT Id FROM ServiceAppointment WHERE Work_Order__c IN :woIds];
			//for all the appts - should be one - create an assigned resource
			if(appts.size()>0) {
				for( ServiceAppointment sa : appts ) {
					sa.SchedStartTime = datetime.newInstance(2019, 4, 19, 11, 00, 0);
					sa.SchedEndTime = datetime.newInstance(2019, 4, 19, 11, 30, 0);

					AssignedResource ar = new AssignedResource(ServiceAppointmentId=sa.Id,ServiceResourceId=sr1.Id);
				update appts;

				insert toInsert;

				List<ServiceAppointment> assignedSA = new List<ServiceAppointment>([SELECT Id,Technician_Name__c FROM ServiceAppointment WHERE Work_Order__c IN :woIds]);
				System.assertEquals(assignedSA.size(), 1);

			} else {


		} else {
			System.assertNotEquals(woIds.size(), 0);

the error occurs on the insert of the assigned resources
insert toInsert;
IF i change the code such that I manually do the status change in the code example:
sa.SchedStartTime = datetime.newInstance(2019, 4, 19, 11, 00, 0);
sa.SchedEndTime = datetime.newInstance(2019, 4, 19, 11, 30, 0);
sa.Status = 'Scheduled';
the error is returned for the update of the service appointments.
update appts;

Feed back greatly appreciated.


Best Answer chosen by Andrew G
Andrew GAndrew G
So i discovered what the issue is and hopefully my explanation makes sense.  (or is 100% correctly explained).

With the FSL managed package, apparently the status transitions are retained in an object which lurks in the darkness of the back end and are not directly available.  I would suspect that the system logic is something like "if I can find a object record that explicitly states the transition is allowed, then allow the transition, otherwise return an error "not allowed".  

So these transitions exist as an object (not a system setting) and you need to use the SeeAllData tag in the test class.
@istest (SeeAllData=true)
The side effect of this is that I had to remove the @testsetup method I was using and move all my test data creation to a test helper class
@testSetup static void setupTestRecords() {  //removed - not compatiable with SeeAllData

Hope this helps others in their coding adventures.



Ajeeth Kumar SAjeeth Kumar S 
sudo sfdx plugins:install @salesforce/lwc-dev-server
Polling for new version(s) to become available on npm... done
    HTTPError: Response code 403 (Forbidden)
Best Answer chosen by Ajeeth Kumar S
Ajeeth Kumar SAjeeth Kumar S

Now i have installed LWC local development server in my mac system. I feel issue with salesforce server.

HI Vikalp Nagar, Can you please try now. 

When I try to run sfdx the same way I have for about 4 years, I get this error message:

'"C:\Users\Desja\AppData\Local\sfdx\client\bin\..\7.209.6-8ba3197\bin\sfdx.cmd"' is not recognized as an internal or external command, operable program or batch file.

>>> Why is it trying to run sfdx from that folder? It's not in that folder!

In this folder: C:\Users\Desja\AppData\Local\sfdx\client I have two sub-folders, "bin" and "7.209.6-8ba3197", the 2nd of which appears to have been created on 9/5/23 (just 2 days ago). The "bin" folder contains 2 files: sf.cmd and sfdx.cmd, while the "7.209.6-8ba3197" folder contains a "bin" folder, which contains a single file named "node.exe"

CLI has become a very valuable tool for me as I support 19 nearly identical orgs for the chapters of a national non-profit that works for the homeless. I have no idea why it has stopped working so mysteriously.

I have been through several existing messages on here that all seem to point to the PATH environment variable. The correct folder is present in my path, but the error message indicates it's trying to run sfdx from that other folder named 7.209.6-8ba3197\bin -- why?

Thank you for any clues to help resolve this.
Best Answer chosen by CRM_Pete
Chase Parker 4Chase Parker 4
Known issue. Upgrade or turn off autoupdate. 



I am following the book "Developement with the Force.com platform" by JasonOuelette.

When creating the Custom Objects, I did not check the box to be visible in a tab, and so I could not add this object to the Custom App I was creating. Now I have a created fields and relationships in the custom object. How do I add this Object to the Custom App?




Best Answer chosen by Admin (Salesforce Developers) 

It looks you havent create custom Tabs while defining custom objects first you need to create custom Tab for new objects Creating Tab Setup -->App Set up---> Create---> Tabs Click on new Tab [drop down shows all untabed objects ] select your object, set Tab style , click Next select profiles Save Adding To App Setup -->App Set up---> Create---> Apps Click on edit, edit available tab section Save Done Thanks, Bala

The following formula will calculate the number of working days (inclusive) between 2 dates. A working day is defined as Monday to Friday. Even if the start or end dates are a weekend, these are accommodated.

IF(AND((5 - (CASE(MOD( Start_Date__c - DATE(1900, 1, 6), 7), 0, 0, 1, 5, 2, 5, 3, 4, 4, 3, 5, 2, 6, 1, 0)) < (CASE(MOD(  End_Date__c  - DATE(1900, 1, 6), 7), 0, 0, 1, 0, 2, 1, 3, 2, 4, 3, 5, 4, 6, 5, 0)) ),
((( End_Date__c  -   Start_Date__c ) + 1) < 7)),
((CASE(MOD(  End_Date__c  - DATE(1900, 1, 6), 7), 0, 0, 1, 0, 2, 1, 3, 2, 4, 3, 5, 4, 6, 5, 0)) - (5 - (CASE(MOD(  Start_Date__c  - DATE(1900, 1, 6), 7), 0, 0, 1, 5, 2, 5, 3, 4, 4, 3, 5, 2, 6, 1, 0)))),
(((FLOOR((( End_Date__c  -  Start_Date__c ) - (CASE(MOD(  Start_Date__c  - DATE(1900, 1, 6), 7), 0, 0, 1, 6, 2, 5, 3, 4, 4, 3, 5, 2, 6, 1, 0))) / 7)) * 5) +
(CASE(MOD(  Start_Date__c  - DATE(1900, 1, 6), 7), 0, 0, 1, 5, 2, 5, 3, 4, 4, 3, 5, 2, 6, 1, 0)) +
(CASE(MOD(  End_Date__c  - DATE(1900, 1, 6), 7), 0, 0, 1, 0, 2, 1, 3, 2, 4, 3, 5, 4, 6, 5, 0))))

The Start Date and End Date fields are custom in the above example and can be replaced as required. If use of a DateTime field is required then the DATEVALUE function will be required.

I also recommend a simple field validation rule is added to check that the End Date is after the Start Date.
Best Answer chosen by Admin (Salesforce Developers) 

This formula seems to work when calculating bt 2 different days. What about taking into account for same day and returns result shoud be a "0"? My result shows a "5" when I entered 9/10/09 and 9/10/09 for both start and end dates. Is there one formula that can include this possiblity?