• Katharine Anderson 13
  • NEWBIE
  • 20 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 6
    Questions
  • 5
    Replies
I keep getting the following error when trying to create a project in VS Code:
13:14:38.625 sfdx force:project:create --projectname VSCodeTest4 --outputdir c:\Users\katharine.anderson\Desktop --template standard
ERROR running force:project:create:  this.sourceRoot is not a function
Any ideas? I tried completely uninstalling and reinstalling both the Salesforce Extension Pack and VS Code. My SFDX CLI is up to date, and so is Java, and I have no plugins. 

Thanks,
Katharine
I initiated a metadata restore using Spanning Backup and it is stuck in a loop. It just keeps trying to deploy the same six apex classes and won't stop. There is nothing in the interface that allows me to stop the deployment and I don't know how it's getting initiated. It's eating up my api calls. I've tried reaching out to their support but no response so far (it's after business hours there, so maybe I'll hear something back tomorrow).

Any suggestions?
I have a strange thing happening on one of my visualforce pages. I need to be able to save the page as a PDF (without using renderAs = "pdf" for reasons that I won't go into here.) When I test it out in my sandbox, it looks fine. But using the same browser, and same exact code, when I print to PDF in production, the font size on the resulting page goes down to ~12pt from 18pt.

Anyone else have something like this happen to them? Any ideas why this would be an issue in production but not in the sandbox???

Thanks,
Katharine
I'm new to coding and I'm having trouble figuring out how to parse the JSON response from Box. What I want to do is to do a callout to box, and then return a list of the items (files) in a folder and then print that list into a visualforce page. I it to show like a related list with the name of the item, the name of the person who uploaded it, and the date that they uploaded it. I also want to filter the list to only show the ones that have been uploaded in the last year.

I found this code in the Box SDK for Salesforce that is their JSON Parser, but I am not sure that I understand it well enough to try to use it: https://github.com/box/box-salesforce-sdk/blob/fd7d28f48fe2a498b08ab2c926433d422e89b30e/src/classes/BoxJsonObject.cls#L170

Can you help me figure out if this is useful for me and how to plug it into my code if so? Currently, when I try, I get this error: EXCEPTION_THROWN [29]|BoxJsonObject.BoxJsonObjectException: Json passed to BoxJsonObject.parseJsonStringArray must start with JSONToken.START_ARRAY

Here is the code that I am currently using that returns the error. Ideally, I would do the callout to Box when the Visualforce page is rendered and then I wouldn't have to store the list in Salesforce and update it before rendering the visualforce page, but I'm not sure if that's possible:
global with sharing class GetMonitoringDocuments {
//instantiate controller
  public GetMonitoringDocuments(ApexPages.StandardController controller){}
//declare variables
  public String folderId {get;set;}
  public String piId {get;set;}
  public String aiId {get;set;}
  public List<ID> ids = new List<ID> {};
//future necessary because it's an http callout to Box using Named Credentials
//Not sure how to filter the list to only show items/files that were uploaded in the monitoring year
@future (callout=true)  
public static void getFolderItems(ID aiId, ID piId, String folderId){
	Http http = new Http();
	HttpRequest req = new HttpRequest();
	req.setMethod('GET');
	req.setEndpoint('callout:BoxForSalesforce/folders/' + folderId + '/items?fields=name,created_at,created_by,shared_link');
            
	HttpResponse response = http.send(req);
            
	system.debug('HttpResponse=>' + response);
//lookup annual inspection record to update
	Annual_Inspection__c AI = [SELECT ID, Monitoring_Documentation__c, Update_Monitoring_Documentation__c
                              FROM Annual_Inspection__c 
                              WHERE ID =: aiId];
 // Update the folder monitoring documentation field with the Parsed JSON (currently getting an error: EXCEPTION_THROWN [29]|BoxJsonObject.BoxJsonObjectException: Json passed to BoxJsonObject.parseJsonStringArray must start with JSONToken.START_ARRAY) 
 //Ideally, rather than putting the parsed JSON into a field, I would want to make the callout when the visualforce page is rendered and then just show it there rather than storing the list in Salesforce.
    BoxJsonObject json = new BoxJsonObject();
    list<String> parsedJSON = json.parseJsonStringArray(response.getBody());
    parsedJson.remove(null);
    AI.Monitoring_Documentation__c = string.join(parsedJSON,'BR()');
    AI.Update_Monitoring_Documentation__c = False;

//Commit the changes.
    update AI;
    
}
//Make it an invocable method so that it can be called by process builder. The code is then run when a checkbox is checked on the record.
@InvocableMethod(label='Get Folder Items' description='Returns the list of folder items.')
  public static void getAIIDs(List<ID> ids) {
    List<Annual_Inspection__c> AIlist = [SELECT id, property_interest__c, Property_Interest__r.MDFolderId__c FROM Annual_Inspection__c WHERE Id in :ids];
    for (Annual_Inspection__c AIs : AIlist) {
      GetMonitoringDocuments.getFolderItems(AIs.id, AIs.property_interest__c, AIs.Property_Interest__r.MDFolderId__c);
    }
  } 
}

Oh and just in case it's useful, here's the unparsed JSON response that I'm working with (with IDs and actual email addresses redacted):
{"total_count":3,"entries":[{"type":"file","id":"230638187456","etag":"0","name":"Preserve preliminary monitoring report 2016.docx","created_at":"2017-09-27T16:16:20-07:00","created_by":{"type":"user","id":"xxxxxxxxxxx","name":"Tester Katharine Anderson","login":"xxx@gmail.com"},"shared_link":null},{"type":"file","id":"xxxxxxxxxxx","etag":"0","name":"Preserve site visit 28 August 2015.docx","created_at":"2017-09-27T16:16:19-07:00","created_by":{"type":"user","id":"xxxxxxxxxxx","name":"Tester Katharine Anderson","login":"xxx@gmail.com"},"shared_link":null},{"type":"file","id":"xxxxxxxxxxx","etag":"0","name":"Posting Authorship pre-2018.csv","created_at":"2017-09-27T16:16:19-07:00","created_by":{"type":"user","id":"xxxxxxxxxxx","name":"Tester Katharine Anderson","login":"xxx@gmail.com"},"shared_link":null}],"offset":0,"limit":100,"order":[{"by":"type","direction":"ASC"},{"by":"name","direction":"ASC"}]}
So I have a trigger that I'm trying to write to update a value on a custom object when it is updated or created. The value should only be updated if the user does not have a certain permission set assigned to them. I have been trying to figure out how to check the user's ID against a list that contains the ids for the users that were assigned to that permision set, but I am fairly new to coding and googling is not working out. Maybe one of you can help? Here is my terrible code that isn't compiling: 
 
trigger UpdatePermissions on box__FRUP__c (before insert, before update) {
    //Create list of Easement Managers based on the Permission Set: 'Easement Management Fields'.
    List<PermissionSetAssignment> EasementManagers = [Select AssigneeId FROM PermissionSetAssignment WHERE PermissionSetId = '0PS0c000000Pi9z'];
    //Check User ID against Assignee ID. If not in list, change FRUP permission to  'Read' instead of 'Read/Write'.
   { for (box__FRUP__c frup : Trigger.New) {
        if (frup.box__Salesforce_User__r.ID IN EasementManagers)
			//do nothing
        } else {
            frup.box__Permission__c = 'Read';
        }
    }
}

 
Okay, I think I'm a little over my head and I could use some guidance. This is one of my first major coding projects and I have hit a wall.
 
My goal is for my users to be able to look at a listview, select several records, and then click a button that will create pdfs from those records, attach them to the records, and then take the attachment and upload it to the Box folder associated with that record's parent.
 
I have uploaded all of my code to this gist: https://gist.github.com/AndersonKatharineTNC/fe722b94215efe76d7be7b0d807d9e5b
 
I have two major issues that I would like help solving:
 
1) Test_PdfGeneratorController errors out because the savePdf() method in PdfGeneratorController2 is a webservices method and it needs do do a mock webservices callout. I generated the wsdl2apex class for PdfGeneratorController2, and I created a test class called WebServiceMockImpl which does the mock response to the callout, but I can't figure out how to get the mock callout to happen in Test_PdfGeneratorController in order to cover the savePdf() method.
 
2) The Attach Monitoring PDF button currently only works as a detail page button. I'd like to update the code in PdfGeneratorController2 to be able to iterate through several selected records in a listview and create attachments for each of them.
 
So, any suggestions? And thanks in advance for taking the time to look at this (sorry if my code is ugly or not well commented. I'll try to update the gist with some better comments soon!)
I keep getting the following error when trying to create a project in VS Code:
13:14:38.625 sfdx force:project:create --projectname VSCodeTest4 --outputdir c:\Users\katharine.anderson\Desktop --template standard
ERROR running force:project:create:  this.sourceRoot is not a function
Any ideas? I tried completely uninstalling and reinstalling both the Salesforce Extension Pack and VS Code. My SFDX CLI is up to date, and so is Java, and I have no plugins. 

Thanks,
Katharine
So I have a trigger that I'm trying to write to update a value on a custom object when it is updated or created. The value should only be updated if the user does not have a certain permission set assigned to them. I have been trying to figure out how to check the user's ID against a list that contains the ids for the users that were assigned to that permision set, but I am fairly new to coding and googling is not working out. Maybe one of you can help? Here is my terrible code that isn't compiling: 
 
trigger UpdatePermissions on box__FRUP__c (before insert, before update) {
    //Create list of Easement Managers based on the Permission Set: 'Easement Management Fields'.
    List<PermissionSetAssignment> EasementManagers = [Select AssigneeId FROM PermissionSetAssignment WHERE PermissionSetId = '0PS0c000000Pi9z'];
    //Check User ID against Assignee ID. If not in list, change FRUP permission to  'Read' instead of 'Read/Write'.
   { for (box__FRUP__c frup : Trigger.New) {
        if (frup.box__Salesforce_User__r.ID IN EasementManagers)
			//do nothing
        } else {
            frup.box__Permission__c = 'Read';
        }
    }
}

 
Okay, I think I'm a little over my head and I could use some guidance. This is one of my first major coding projects and I have hit a wall.
 
My goal is for my users to be able to look at a listview, select several records, and then click a button that will create pdfs from those records, attach them to the records, and then take the attachment and upload it to the Box folder associated with that record's parent.
 
I have uploaded all of my code to this gist: https://gist.github.com/AndersonKatharineTNC/fe722b94215efe76d7be7b0d807d9e5b
 
I have two major issues that I would like help solving:
 
1) Test_PdfGeneratorController errors out because the savePdf() method in PdfGeneratorController2 is a webservices method and it needs do do a mock webservices callout. I generated the wsdl2apex class for PdfGeneratorController2, and I created a test class called WebServiceMockImpl which does the mock response to the callout, but I can't figure out how to get the mock callout to happen in Test_PdfGeneratorController in order to cover the savePdf() method.
 
2) The Attach Monitoring PDF button currently only works as a detail page button. I'd like to update the code in PdfGeneratorController2 to be able to iterate through several selected records in a listview and create attachments for each of them.
 
So, any suggestions? And thanks in advance for taking the time to look at this (sorry if my code is ugly or not well commented. I'll try to update the gist with some better comments soon!)