• Liz Gibbons 16
  • NEWBIE
  • 79 Points
  • Member since 2015
  • Programmer Analyst
  • Digital On-Ramps, Drexel University


  • Chatter
    Feed
  • 0
    Best Answers
  • 2
    Likes Received
  • 0
    Likes Given
  • 22
    Questions
  • 31
    Replies
I am working on a managed package and have everything working before I package it. When I then deploy it to a sandbox to test, odd things break: a hardcoded link redirects differently and a controller class that had worked perfectly doesn't provide the correct data to its VF page.  

Any thoughts on why this might be?
Hello,

We have clients upload documents, images, ppt, pdfs, etc and link to google docs, videos, websites, etc as attachments to a custom object in our Customer Community and we want to display thumbnails of these assets. 

Anyone have thoughts on how to accomplish this? I've found ways to display the images as thumbnails, but am confounded by how to display the variety of file types and links. 

Thanks in advance!
I am trying to create a table that displays Asset__c records grouped by a picklist field, Category__c. I've got the table displaying the Categories, but cannot get the Assets to display. Here's what is looks like now: User-added image
Here's the code I've got so far:
Class
public with sharing class ListViewController {
	
	public List<String> categories {get; set;}
	public List<Asset__c> tessa {get; set;}
	
	public ListViewController(){
		categories = new List<String>();
		Schema.DescribeFieldResult fieldResult = Asset__c.Category__c.getDescribe();
		System.debug(fieldResult);
		List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues();
		System.debug('--ple-->> ' + ple);
		for(Schema.PicklistEntry f : ple){
			categories.add(f.getLabel());
		}
		tessa = [select Name, Category__c, LastModifiedDate from Asset__c];
	
	}
         
}

Table
<div class="view" id="list">
	<div class="panel panel-default">
		<div class="panel-body">
			<div class="row">
				<div class="col-lg-2">
				<div class="form-group">
					<input type="text" class="form-control input-sm form-control-flat" placeholder="{!$Label.LBL_Search_Asset}" onkeyup="checksearch(this);"/>
				</div>
				</div>
			</div>
			<apex:form id="tableAssets">
				<table id="basic-datatable" class="table table-bordered">
					<thead>
						<tr>
							<th id="first-th" class="click-header" onclick="toogleall(this);"><i class="fa fa-plus-square-o" title="{!$Label.LBL_Show_Hide_All}"></i></th>
							<th width="60%">{!$ObjectType.Asset__c.Fields.Name.Label}</th>
							<th>{!$ObjectType.Asset__c.Fields.LastModifiedDate.Label}</th>
						</tr>
					</thead>
					<tbody>
						<apex:variable var="index" value="{!0}" />
						<apex:repeat value="{!categories}" var="cat">
							<tr class="category-row" id="{!cat}" onclick="togglerows(this);">
								<td class="hidden"><label></label></td>
								<td colspan="3"><i class="fa fa-plus-square-o"></i>&nbsp;&nbsp;<span class="name">{!cat}</span></td>
								<td class="hidden"><span></span></td>
							</tr>
							<apex:repeat value="{!tessa}" var="a">
									<tr class="category-in" style="display:none;">
										<td class="asset-name"><span>{!a.Name}</span></td>
									</tr>
								<apex:variable var="index" value="{!index+1}" />
							</apex:repeat>
						</apex:repeat>
					</tbody>
				</table>
			</apex:form>
		</div>
	</div>
</div>


       
 
I'm trying to edit a controller to display a list of objects on a vf page, sorting by a picklist on that object. Currently it displays the picklist values and a count of the objects with that value, but I would like to toggle between that and a list view (included below).

I inherited the code and the developers gave no documentation (All comments in the code I wrote after inheriting it). Any thoughts on how to accomplish this? I believe the issue stems from the Assets not associating properly with the picklist values. The values display in the table, but the Assets do not.

Here's the controller:
public without sharing class LPAssetController {

	/* Grabs motivislp__ */
	public String getPrefix() {
		return LPUtils.getPackagePrefix();
	}

	public LPAssetController() {
	}

	private ApexPages.StandardController stdctrl;

	public LPAssetController(ApexPages.StandardController stdController) {
		stdctrl = stdController;
	}

	// COMMON
	/* Category picklist for Content*/
	public Schema.PicklistEntry getCategoryParam() {
		Schema.PicklistEntry result;
		String cParam = ApexPages.currentPage().getParameters().get('c');
		if (String.isNotBlank(cParam)) {
			String categoryNotFiltred = cParam.toLowerCase();
			for (Schema.PicklistEntry pe : SObjectType.Asset__c.fields.Category__c.getPicklistValues()) {
				if (pe.getValue().toLowerCase() == categoryNotFiltred) {
					result = pe;
					break;
				}
			}
		}
		return result;
	}

	// EDIT/VIEW MODE

	public Asset__c tesla { get; set; } //instantiate object record
	public Blob imgBody { get; set; } 
	public String imgFileName { get; set; }
	public String imgContentType { get; set; }
	public String linkText { get; set; }
	public LPFieldLayout flayout { get; set; }
	public Boolean isDel { get { return isDel == true; } set; }
	public String attachmentId { get; set; }
	public Boolean fileIndicator { get; set; }
	public String LBL_Welcome_to_Portfolio {
		get {
			return String.format(Label.LBL_Welcome_to_Portfolio_c, new List<String>{ PortfolioOwnerName });
		}
	}

	/* controls LPAssetEdit.page */
	public void initFromEdit() {
		init();
	}

	public LPLearnerProfileController.EliforpPage efp { get; set; }

	/* controls LPAssetDetail.page */
	public void initFromView() {
		init();
		efp = new LPLearnerProfileController.EliforpPage(tesla);
	}

	private void init() {
		lpMode = String.isNotBlank(ApexPages.currentPage().getParameters().get('lp'));

		List<Asset__c> check = [SELECT Id, IsDeleted FROM Asset__c WHERE Id = :stdctrl.getId() ALL ROWS];
		isDel = (!check.isEmpty() && check[0].IsDeleted == false) ? false : true;
		tesla = isDel ? new Asset__c() : (Asset__c)stdctrl.getRecord();

		/* using Notes and Attachments to handle upload of Content */
		List<String> hardFields = new List<String> {
			'Id', 'Name', 'Link__c', 'Category__c', 'Status__c',
			'(SELECT Id, IsNote, Title FROM NotesAndAttachments WHERE IsNote = false ORDER BY CreatedDate DESC LIMIT 1)'
		};

		/* Fields displayed on LPAssetEdit and LPAssetDetail */
		flayout = new LPFieldLayout(
			tesla.Id,
			SObjectType.Asset__c.FieldSets.Edit_Assets,
			SObjectType.Asset__c,
			hardFields,
			LPUtils.getPackagePrefix()
		);

		/* After save, display LPAssetDetail */
		if (tesla.Id != NULL) {
			tesla = (Asset__c)flayout.getRecord();
		}
		/* if Category NULL, return error message */
		else {
			Schema.PicklistEntry pe2 = getCategoryParam();
			if (pe2 != NULL) {
				tesla.Category__c = pe2.getValue();
			}
		}
	}

	public String getDelRedirectParam() {
		String c = (tesla == NULL) ? '' : tesla.Category__c;
		String lp = lpMode ? ApexPages.currentPage().getParameters().get('lp') : '';
		return ((String.isNotBlank(c)) ? 'c='+c : '') + ((String.isNotBlank(lp) && String.isNotBlank(lp)) ? '&' : '') + ((String.isNotBlank(lp)) ? 'lp='+lp : '');
	}

	
	public PageReference saveAsset() {
		PageReference pr;
		if (tesla.Id == NULL && tesla.User__c == NULL) {
			tesla.User__c = UserInfo.getUserId();
		}
		try {
			/* append http, etc to links */
			if (String.isNotBlank(linkText)) {
				tesla.Link__c = (!linkText.startsWith('http://') && !linkText.startsWith('https://')) ? ('http://' + linkText) : linkText;
				upsert tesla;
			}
			else if (imgBody != NULL && String.isNotBlank(imgFileName)) {
				tesla.Link__c = NULL;
				upsert tesla;
			/* creates Attachment to Asset__c record */
				insert new Attachment(
					Name = imgFileName,
					Body = imgBody,
					ParentId = tesla.Id,
					ContentType = imgContentType
				);
			}
			/* Attachment already exists */
			else if (attachmentId != 'false' && String.isNotBlank(attachmentId)) {
				tesla.Link__c = NULL;
				upsert tesla;

				List<Attachment> acList = [SELECT Id, Name, Body, ContentType, ParentId FROM Attachment WHERE Id = :attachmentId];
				if (acList.size() > 0) {
					Attachment ac = acList[0];
					insert new Attachment(
						Name = ac.Name,
						Body = ac.Body,
						ParentId = tesla.Id,
						ContentType = ac.ContentType,
						Description = 'CreatedByAsset'
					);
					
					//LP-87 ----->
					try {
						delete [SELECT Id FROM Asset__c WHERE Id = :ac.ParentId];
					}
					catch(Exception e) {
						System.debug('Delete problem!');
					}
					//LP-87 <-----
				}
			}
			else if (fileIndicator) {
				tesla.Link__c = NULL;
				upsert tesla;
			}
			else {
				upsert tesla;
			}
			pr = Page.LPAssetDetail;
			pr.getParameters().put('Id', tesla.Id);
			pr.setRedirect(true);
		}
		catch (Exception e) {
			ApexPages.addMessages(e);
		}
		return pr;
	}

	public PageReference clearAttach() {
		// delete asset when "cancel" 
		Cookie createdAsset = ApexPages.currentPage().getCookies().get('CreatedAsset');

		if (createdAsset != null) {
			String createdAssetValue = createdAsset.getValue();
			if (String.isNotBlank(createdAssetValue) || createdAssetValue != 'null') {
				createdAssetValue = String.escapeSingleQuotes(createdAssetValue);
				try {
					delete [SELECT Id FROM Attachment WHERE Id = :createdAssetValue];
				} catch(Exception e) {
					System.debug('Delete problem! ' + e);
				}
			}
		}
		//LP-87 -----> Deletes Asset__c record
		Cookie assetCook = ApexPages.currentPage().getCookies().get('AssetIdToDelete');

		if (assetCook != null) {
			String cookieValue = assetCook.getValue();
			if (String.isNotBlank(cookieValue) || cookieValue != 'null') {
				String escapeCookieValue = String.escapeSingleQuotes(cookieValue);
				try {
					delete [SELECT Id FROM Asset__c WHERE Id = :escapeCookieValue];
				}
				catch(Exception e) {
					System.debug('Delete problem! ' + e);
				}
			}
		}
		/* redirects to LPAssets */
		String retURLParametr = ApexPages.currentPage().getParameters().get('retURL');
		if (String.isNotBlank(retURLParametr)) {
			PageReference pr = new PageReference(retURLParametr);
			pr.setRedirect(true);
			return pr;
		}
		PageReference pr = Page.LPAssets;
		pr.setRedirect(true);
		return pr;
		//LP-87 <-----
	}

	public void clearAttachSave() {
		clearAttachContact();
		clearAttachAsset(false);
	}

	public void clearAttachContact() {
		String contactId = [SELECT ContactId FROM User WHERE Id = :UserInfo.getUserId()][0].ContactId;
		delete [SELECT Id FROM Attachment WHERE Description = 'CreatedByAsset' AND ParentId = :contactId];
	}

	public void clearAttachAsset(Boolean cancel) {
		List<Attachment> attachToDelete;
		Attachment attachWithDescription;
		attachToDelete = [SELECT Id FROM Attachment WHERE Description = 'CreatedByAsset' AND ParentId = :tesla.Id ORDER BY CreatedDate DESC];
		if (attachToDelete.size() > 0) {
			if (!cancel && String.isBlank(linkText)) {
				attachWithDescription = attachToDelete[0];
				attachWithDescription.description = '';
				update attachWithDescription;
				attachToDelete.remove(0);
			}
			delete attachToDelete;
		}
	}

	/* displays the image for ePortfolio shareable side */
	public static String getHeroImageId() {
		return LP_Template_Settings__c.getInstance().Hero_Image__c;
	}
	public static Boolean getHasCustomHeroImage() {
		return String.isNotBlank(LP_Template_Settings__c.getInstance().Hero_Image__c);
	}

	/* called from Save & Add button on LPLearnerProfileEdit */
	public PageReference saveAndAddAsset() {
		Boolean createMode = getShowCreateAddBtn();
		PageReference pr = saveAsset();
		if (createMode && tesla.Status__c != 'Inactive') {
			Id lpParamId = Id.valueOf(ApexPages.currentPage().getParameters().get('lp'));
			insert new Asset_Learner_Profile__c(
				Asset__c = tesla.Id,
				Learner_Profile__c = lpParamId
			);
			String retURLParametr = ApexPages.currentPage().getParameters().get('retUrl');
			if (String.isBlank(retURLParametr)) {
				pr = Page.LPAssets;
				pr.getParameters().put('lp', lpParamId);
				pr.setRedirect(true);
			}
			else {
				pr = new PageReference(retURLParametr);
			}
		}
		return pr;
	}

	public void submitAddRemoveLP() {
		Set<Id> deleteAssetProfile = new Set<Id>();
		List<Asset_Learner_Profile__c> createAssetProfile = new List<Asset_Learner_Profile__c>();
		for (LPLearnerProfileController.Eliforp elItem : efp.lps) {
			if (elItem.initialyChecked != elItem.checked) {
				if (elItem.checked) {
					createAssetProfile.add(
						new Asset_Learner_Profile__c(
							Asset__c = tesla.Id,
							Learner_Profile__c = elItem.Id
						)
					);
				}
				else {
					deleteAssetProfile.add(elItem.Id);
				}
			}
		}
		if (createAssetProfile.size() > 0) {
			insert createAssetProfile;
		}
		if (deleteAssetProfile.size() > 0) {
			delete [SELECT Id FROM Asset_Learner_Profile__c WHERE Asset__c = :tesla.Id AND Learner_Profile__c IN :deleteAssetProfile];
		}
		initFromView();
	}

	public Boolean getShowMyLPbtn() {
		return SObjectType.Asset_Learner_Profile__c.isCreateable() && tesla.Status__c != 'Inactive';
	}

	public String getLearnerProfileName() {
		Id lpParamId = Id.valueOf(ApexPages.currentPage().getParameters().get('lp'));
		return getShowCreateAddBtn() ? [SELECT Name FROM Learner_Profile__c WHERE Id = :lpParamId].Name : '';
	}

	public Boolean getShowCreateAddBtn() {
		return lpMode && tesla.Id == NULL;
	}

	public List<String> getAssetLink() {
		List<String> resultList = new List<String> { '', '', 'fa-file-o' };
		if (String.isNotBlank(tesla.Link__c)) {
			resultList = new List<String> { tesla.Link__c, tesla.Link__c, 'fa-link' };
		}
		else if (tesla.NotesAndAttachments.size() > 0) {
			String[] parts = tesla.NotesAndAttachments[0].Title.split('\\.');
			String ext = parts[parts.size() - 1].toLowerCase();
			//ext = !CommunitySearchController.AWESOME_FILE_TYPES.containsKey(ext) ? 'fa-file-o' : CommunitySearchController.AWESOME_FILE_TYPES.get(ext);
			resultList = new List<String> {
				tesla.NotesAndAttachments[0].Title,
				LPUtils.checkUrl('/servlet/servlet.FileDownload?file=' + tesla.NotesAndAttachments[0].Id),
				'fa-file-o'
			};
		}
		return resultList;
	}

	public PageReference deleteAsset() {
		PageReference pr;
		try {
			delete tesla;
			pr = Page.LPAssets;
			if (lpMode) {
				pr.getParameters().put('lp', Id.valueOf(ApexPages.currentPage().getParameters().get('lp')));
			}
			pr.getParameters().put('c', tesla.Category__c);
			pr.setRedirect(true);
		}
		catch (Exception e) {
			ApexPages.addMessages(e);
		}
		return pr;
	}

	public String getDeleteConfirmMessage() {
		Boolean acdc = false;
		for (LPLearnerProfileController.Eliforp eleItem : efp.lps) {
			acdc = (eleItem.checked == true) ? true : acdc;
		}
		return acdc ? Label.LBL_Delete_Asset : Label.LBL_Delete_Asset_message;
	}

	public Boolean getInitialActiveStatus() {
		return tesla.Status__c == 'Active';
	}

	// LIST MODE 

	private Boolean listMode;
	private Boolean categoryMode;
	private final static String ALIAS_PARAM_DIVIDER = '?u=';

	public Boolean lpMode { get { return lpMode == NULL ? false : lpMode; } set; }
	public Boolean wrongProfile { get { return wrongProfile == NULL ? false : wrongProfile; } set; }
	public transient Learner_Profile__c currentLearnerProfile { get; set; }

	public void initFromList() {
		listMode = getCategoryParam() == NULL;
		categoryMode = !listMode;
		String lpParam = ApexPages.currentPage().getParameters().get('lp');
		lpMode = String.isNotBlank(lpParam);
		currentLearnerProfile = new Learner_Profile__c();
		if (lpMode) {
			String escapedParam = String.escapeSingleQuotes(lpParam);
			List<Learner_Profile__c> checkLPlist = [
				SELECT Id, Status__c, Name, Description__c
				FROM Learner_Profile__c
				WHERE Id = :String.escapeSingleQuotes(lpParam)
					AND OwnerId = :UserInfo.getUserId()
			];
			wrongProfile = checkLPlist.size() == 0;
			currentLearnerProfile = wrongProfile ? new Learner_Profile__c() : checkLPlist[0];
		}
		
	}

	public Boolean getInactiveProfile() {
		Set<String> activeProfileSet = new Set<String> { 'Active', 'Draft' };
		return lpMode && !activeProfileSet.contains(currentLearnerProfile.Status__c);
	}

	public String getLPStatusColorStyle() {
		Map<String, String> tm = new Map<String, String> { 'Active' => 'text-success', 'Draft' => 'text-warning', 'Inactive' => 'text-danger' };
		return tm.get(currentLearnerProfile.Status__c);
	}

	public String getLearnerProfilePageLink() {
		return LPLearnerProfileController.BASE_LP_LINK + currentLearnerProfile.Id;
	}

	public Boolean getShowLPbtns() {
		return lpMode && !categoryMode;
	}

	public Boolean getAddFromCategoryBtn() {
		return lpMode && categoryMode && SObjectType.Asset_Learner_Profile__c.isCreateable();
	}

	public String getUrlForAddFromCategory() {
		return prepareUrl(Page.LPMyAssets.getUrl()) + addCategoryLPParam('?');
	}

	public String getUrlForNewAsset() {
		return prepareUrl(Page.LPAssetEdit.getUrl())
				+ '?retURL=' + EncodingUtil.urlEncode(prepareUrl(Page.LPAssets.getUrl() + addCategoryLPParam('?')), 'UTF-8')
				+ addCategoryLPParam('&');
	}

	public String getUrlForEditAsset() {
		return prepareUrl(Page.LPAssetEdit.getUrl())
				+ '?id=' + tesla.Id
				+ '&retURL=' + EncodingUtil.urlEncode(prepareUrl(Page.LPAssetDetail.getUrl()) + '?id=' + tesla.Id, 'UTF-8');
	}

	public String getUrlForEditLearnerProfile() {
		String lpId = ApexPages.currentPage().getParameters().get('lp');
		return prepareUrl(Page.LPLearnerProfileEdit.getUrl())
				+ '?id=' + lpId
				+ '&retURL=' + EncodingUtil.urlEncode(prepareUrl(Page.LPAssets.getUrl()) + '?lp=' + lpId, 'UTF-8');
	}

	public String getLearnerProfileLink() {
		return lpMode ? ('&lp=' + String.escapeSingleQuotes(ApexPages.currentPage().getParameters().get('lp'))) : '';
	}

	private static String prepareUrl(String inUncouthUrl) {
		return inUncouthUrl.replace('/apex/', Site.getPathPrefix() + '/');
	}

	private String addCategoryLPParam(String inGlue) {
		String result = '';
		String cp = ApexPages.currentPage().getParameters().get('c');
		if (String.isNotBlank(cp)) {
			result += inGlue +'c=' + EncodingUtil.urlEncode(cp, 'UTF-8');
			inGlue = '&';
		}
		String lpp = ApexPages.currentPage().getParameters().get('lp');
		if (String.isNotBlank(lpp)) {
			result += inGlue +'lp=' + lpp;
		}
		return result;
	}

	public List<Yrogetac> getCategories() {
		List<Yrogetac> resultList = new List<Yrogetac>();
		if (listMode == true && !wrongProfile) {
			String yQuery = 'SELECT COUNT(Id) Counter, Category__c Cat FROM Asset__c WHERE User__c =\'' + UserInfo.getUserId() + '\'';
			if (lpMode) {
				yQuery += ' AND Id IN (SELECT Asset__c FROM Asset_Learner_Profile__c WHERE Learner_Profile__c = \'';
				yQuery += String.escapeSingleQuotes(ApexPages.currentPage().getParameters().get('lp')) + '\')';
			}
			yQuery += 'GROUP BY Category__c ORDER BY Category__c';
			Map<String, Yrogetac> filledCategoriesMap = new Map<String, Yrogetac>();
			for (AggregateResult arItem : Database.query(yQuery)) {
				String tc = (String)arItem.get('Cat');
				filledCategoriesMap.put((String.isBlank(tc) ? 'none' : tc.toLowerCase()), new Yrogetac(arItem));
			}
			for (Schema.PicklistEntry pe : SObjectType.Asset__c.fields.Category__c.getPicklistValues()) {
				String tc2 = pe.getValue().toLowerCase();
				resultList.add(filledCategoriesMap.containsKey(tc2) ? filledCategoriesMap.get(tc2) : new Yrogetac(pe.getValue()));
			}
		}
		return resultList;
	}

	public List<Tessa> getAssets() {
		List<Tessa> resultList = new List<Tessa>();
		if (categoryMode == true && !wrongProfile) {
			String aQuery = 'SELECT Id, Name, Link__c, Description__c, Type__c, Status__c, CreatedDate, (SELECT Id, Name, BodyLength FROM Attachments ORDER BY CreatedDate DESC LIMIT 1)';
			aQuery += ' FROM Asset__c WHERE Category__c = \'' + String.escapeSingleQuotes(ApexPages.currentPage().getParameters().get('c')) + '\'';
			aQuery += ' AND User__c =\'' + UserInfo.getUserId() + '\'';
			if (lpMode) {
				aQuery += ' AND Id IN (SELECT Asset__c FROM Asset_Learner_Profile__c WHERE Learner_Profile__c = \'';
				aQuery += String.escapeSingleQuotes(ApexPages.currentPage().getParameters().get('lp')) + '\')';
			}
			for (Asset__c aItem : Database.query(aQuery)) {
				resultList.add(new Tessa(aItem));
			}
		}
		return resultList;
	}

	private static Map<String, String> AWESOME_FILE_TYPES = new Map<String, String> {
		'link' => 'fa-link', 'xls' => 'fa-file-excel-o', 'xlsx' => 'fa-file-excel-o', 'pdf' => 'fa-file-pdf-o',
		'doc' => 'fa-file-word-o', 'docx' => 'fa-file-word-o', 'ppt' => 'fa-file-pdf-o', 'pptx' => 'fa-file-pdf-o',
		'txt' => 'fa-file-text-o', 'png' => 'fa-file-image-o', 'gif' => 'fa-file-image-o', 'jpeg' => 'fa-file-image-o',
		'jpg' => 'fa-file-image-o', 'bmp' => 'fa-file-image-o'
	};

	// PAGE MODE

	public Boolean portfolioFound { get; set; }
	public String portfolioOwnerName { get; set; }
	public String portfolioDescription { get; set; }

	public void initFromPage() {
		try {
			Id lpParamId = Id.valueOf(ApexPages.currentPage().getParameters().get('lp'));
			Learner_Profile__c checklp = [
				SELECT Id, Description__c, Owner.Id, Owner.Name
				FROM Learner_Profile__c
				WHERE Id = :lpParamId
					AND (Status__c = 'Active' OR (Status__c = 'Draft' AND OwnerId = :UserInfo.getUserId()))
			];

			List<User> uList = [
				SELECT Id, Contact.Id, Contact.FirstName, Contact.LastName
				FROM User
				WHERE Id = :checklp.Owner.Id
					AND ContactId != null
			];
			portfolioOwnerName = uList.isEmpty() ? checklp.Owner.Name : uList[0].Contact.FirstName + ' ' + uList[0].Contact.LastName;
			portfolioDescription = checklp.Description__c;
			portfolioFound = true;
		}
		catch (Exception e) {
			portfolioFound = false;
		}
	}

	/* grabs all the populated Categories for a particular ePortfolio */
	public List<Yrogetac> getCategoriesWithAssets() {
		List<Yrogetac> resultList = new List<Yrogetac>();
		if (portfolioFound) {
			Map<String, Yrogetac> assemblyCategoryMap = new Map<String, Yrogetac>();
			Id lpParamId = Id.valueOf(ApexPages.currentPage().getParameters().get('lp'));
			for (Asset__c aItem : [
						SELECT Id, Name, Link__c, Description__c, Type__c, Status__c, Category__c, CreatedDate,
							(SELECT Id, Name, BodyLength FROM Attachments ORDER BY CreatedDate DESC LIMIT 1)
						FROM Asset__c
						WHERE Id IN (SELECT Asset__c FROM Asset_Learner_Profile__c WHERE Learner_Profile__c = :lpParamId)
				]) {

				String catUnique = String.isBlank(aItem.Category__c) ? 'none' : aItem.Category__c;
				catUnique = catUnique.replace(' ', '').toLowerCase();
				if (!assemblyCategoryMap.containsKey(catUnique)) {
					assemblyCategoryMap.put(catUnique, new Yrogetac(aItem.Category__c, catUnique));
				}
				assemblyCategoryMap.get(catUnique).assets.add(new Tessa(aItem));
			}
			for (Schema.PicklistEntry pe : SObjectType.Asset__c.fields.Category__c.getPicklistValues()) {
				String tc3 = pe.getValue().replace(' ','').toLowerCase();
				if (assemblyCategoryMap.containsKey(tc3)) {
					resultList.add(assemblyCategoryMap.get(tc3));
				}
			}
		}
		return resultList;
	}

	public String getLogoUrl() {
		LP_Template_Settings__c lpts = LP_Template_Settings__c.getOrgDefaults();
		return (lpts == NULL || String.isBlank(lpts.Header_Logo__c)) ? NULL : lpts.Header_Logo__c;
	}

	public PageReference getSiteTemplatePage() {
		return LPUtils.getSiteTemplatePage();
	}

	// WRAPPER CLASSES
	/* grabs Asset__c records for display on Category pages */
	public class Tessa {
		public String id { get; set; }
		public String name { get; set; }
		public String atype { get; set; }
		public String link { get; set; }
		public String description { get; set; }
		public String icon { get; set; }
		public String size { get; set; }
		public String file { get; set; }
		public String status { get; set; }
		public String dshot { get; set; }

		public Tessa(Asset__c ina) {
			id = ina.Id;
			name = ina.Name;
			atype = ina.Type__c;
			description = ina.Description__c;
			dshot = String.isBlank(description) ? '' : description.abbreviate(32);
			file = ina.Status__c == 'Inactive' ? 'f-txt' : 'f-docx';
			status = ina.Status__c;
			if (String.isNotBlank(ina.Link__c)) {
				icon = 'fa-link';
				link = ina.Link__c;
			}
			else if (ina.Attachments.size() > 0) {
				String[] parts = ina.Attachments[0].Name.split('\\.');
				String ext = parts[parts.size() - 1].toLowerCase();
				icon = !AWESOME_FILE_TYPES.containsKey(ext) ? 'fa-file-o' : AWESOME_FILE_TYPES.get(ext);
				size = LPUtils.convertFileSize(ina.Attachments[0].BodyLength);
				link = LPUtils.checkUrl('/servlet/servlet.FileDownload?file=' + ina.Attachments[0].Id);
			}
			else {
				link = '#';
				icon = 'fa-file-o';
			}
		}
	}

	/* grabs lists from above to display count */
	public class Yrogetac {
		public String name { get; set; }
		public Integer counter { get; set; }
		public List<Tessa> assets { get; set; }
		public String catid { get; set; }

		public Yrogetac(AggregateResult inar) {
			name = (String)inar.get('Cat');
			counter = (Integer)inar.get('Counter');
		}

		public Yrogetac(String inc) {
			name = inc;
			counter = 0;
		}

		public Yrogetac(String inc, String inid) {
			name = inc;
			catid = inid;
			assets = new List<Tessa>();
		}

		public String getItemString() {
			List<String> parts = Label.LBL_Item_Items.split(';');
			String single = parts[0];
			String plural = parts.size() > 1 ? parts[1] : parts[0];
			return String.valueOf(counter) + ' ' + (counter == 1 ? single : plural);
		}
	}
	
}

And here's the vf page section:
<!-- START LIST VIEW -->
<div class="view" id="list">
<div class="panel panel-default">
	<div class="panel-body">
		<div class="row">
	        	<div class="col-lg-2">
			<div class="form-group">
			    <input type="text" class="form-control input-sm form-control-flat" placeholder="{!$Label.LBL_Search_Asset}" onkeyup="checksearch(this);"/>
			</div>
  		   </div>
		</div>
		<apex:form id="tableAssets">
			<table id="basic-datatable" class="table table-bordered">
			       <thead>
		 		     <tr>
         				<th id="first-th" class="click-header" onclick="toogleall(this);"><i class="fa fa-plus-square-o" title="{!$Label.LBL_Show_Hide_All}"></i></th>
	         		     <th width="60%">{!$ObjectType.Asset__c.Fields.Name.Label}</th>
				       <th>{!$ObjectType.Asset__c.Fields.LastModifiedDate.Label}</th>
					</tr>
				</thead>
					<tbody>
					<apex:variable var="index" value="{!0}" />
						<apex:repeat value="{!Categories}" var="c">
						<tr class="category-row" onclick="togglerows(this);">
							<td class="hidden"><label></label></td>
							<td colspan="3"><i class="fa fa-plus-square-o"></i>&nbsp;&nbsp;<span class="name">{!c.name}</span></td>
							<td class="hidden"><span></span></td>
						</tr>
						<apex:repeat value="{!Assets}" var="a">
						<tr class="category-in" style="display:none;">
							<td class="asset-name"><span>{!a.name}</span></td>
						</tr>
							<apex:variable var="index" value="{!index+1}" />
						</apex:repeat>
					</apex:repeat>
					</tbody>
				</table>
			</apex:form>
		</div>
	</div>
</div>
<!-- END LIST VIEW -->


 
I'm trying to edit a controller to display a list of objects on a vf page, sorting by a picklist on that object. Currently it displays the picklist values and a count of the objects with that value, but I would like to toggle between that and a list view (included below).

I inherited the code and the developers gave no documentation (All comments in the code I wrote after inheriting it). Any thoughts on how to accomplish this?

Here's the controller:
public without sharing class LPAssetController {

	/* Grabs motivislp__ */
	public String getPrefix() {
		return LPUtils.getPackagePrefix();
	}

	public LPAssetController() {
	}

	private ApexPages.StandardController stdctrl;

	public LPAssetController(ApexPages.StandardController stdController) {
		stdctrl = stdController;
	}

	// COMMON
	/* Category picklist for Content*/
	public Schema.PicklistEntry getCategoryParam() {
		Schema.PicklistEntry result;
		String cParam = ApexPages.currentPage().getParameters().get('c');
		if (String.isNotBlank(cParam)) {
			String categoryNotFiltred = cParam.toLowerCase();
			for (Schema.PicklistEntry pe : SObjectType.Asset__c.fields.Category__c.getPicklistValues()) {
				if (pe.getValue().toLowerCase() == categoryNotFiltred) {
					result = pe;
					break;
				}
			}
		}
		return result;
	}

	// EDIT/VIEW MODE

	public Asset__c tesla { get; set; } //instantiate object record
	public Blob imgBody { get; set; } 
	public String imgFileName { get; set; }
	public String imgContentType { get; set; }
	public String linkText { get; set; }
	public LPFieldLayout flayout { get; set; }
	public Boolean isDel { get { return isDel == true; } set; }
	public String attachmentId { get; set; }
	public Boolean fileIndicator { get; set; }
	public String LBL_Welcome_to_Portfolio {
		get {
			return String.format(Label.LBL_Welcome_to_Portfolio_c, new List<String>{ PortfolioOwnerName });
		}
	}

	/* controls LPAssetEdit.page */
	public void initFromEdit() {
		init();
	}

	public LPLearnerProfileController.EliforpPage efp { get; set; }

	/* controls LPAssetDetail.page */
	public void initFromView() {
		init();
		efp = new LPLearnerProfileController.EliforpPage(tesla);
	}

	private void init() {
		lpMode = String.isNotBlank(ApexPages.currentPage().getParameters().get('lp'));

		List<Asset__c> check = [SELECT Id, IsDeleted FROM Asset__c WHERE Id = :stdctrl.getId() ALL ROWS];
		isDel = (!check.isEmpty() && check[0].IsDeleted == false) ? false : true;
		tesla = isDel ? new Asset__c() : (Asset__c)stdctrl.getRecord();

		/* using Notes and Attachments to handle upload of Content */
		List<String> hardFields = new List<String> {
			'Id', 'Name', 'Link__c', 'Category__c', 'Status__c',
			'(SELECT Id, IsNote, Title FROM NotesAndAttachments WHERE IsNote = false ORDER BY CreatedDate DESC LIMIT 1)'
		};

		/* Fields displayed on LPAssetEdit and LPAssetDetail */
		flayout = new LPFieldLayout(
			tesla.Id,
			SObjectType.Asset__c.FieldSets.Edit_Assets,
			SObjectType.Asset__c,
			hardFields,
			LPUtils.getPackagePrefix()
		);

		/* After save, display LPAssetDetail */
		if (tesla.Id != NULL) {
			tesla = (Asset__c)flayout.getRecord();
		}
		/* if Category NULL, return error message */
		else {
			Schema.PicklistEntry pe2 = getCategoryParam();
			if (pe2 != NULL) {
				tesla.Category__c = pe2.getValue();
			}
		}
	}

	public String getDelRedirectParam() {
		String c = (tesla == NULL) ? '' : tesla.Category__c;
		String lp = lpMode ? ApexPages.currentPage().getParameters().get('lp') : '';
		return ((String.isNotBlank(c)) ? 'c='+c : '') + ((String.isNotBlank(lp) && String.isNotBlank(lp)) ? '&' : '') + ((String.isNotBlank(lp)) ? 'lp='+lp : '');
	}

	
	public PageReference saveAsset() {
		PageReference pr;
		if (tesla.Id == NULL && tesla.User__c == NULL) {
			tesla.User__c = UserInfo.getUserId();
		}
		try {
			/* append http, etc to links */
			if (String.isNotBlank(linkText)) {
				tesla.Link__c = (!linkText.startsWith('http://') && !linkText.startsWith('https://')) ? ('http://' + linkText) : linkText;
				upsert tesla;
			}
			else if (imgBody != NULL && String.isNotBlank(imgFileName)) {
				tesla.Link__c = NULL;
				upsert tesla;
			/* creates Attachment to Asset__c record */
				insert new Attachment(
					Name = imgFileName,
					Body = imgBody,
					ParentId = tesla.Id,
					ContentType = imgContentType
				);
			}
			/* Attachment already exists */
			else if (attachmentId != 'false' && String.isNotBlank(attachmentId)) {
				tesla.Link__c = NULL;
				upsert tesla;

				List<Attachment> acList = [SELECT Id, Name, Body, ContentType, ParentId FROM Attachment WHERE Id = :attachmentId];
				if (acList.size() > 0) {
					Attachment ac = acList[0];
					insert new Attachment(
						Name = ac.Name,
						Body = ac.Body,
						ParentId = tesla.Id,
						ContentType = ac.ContentType,
						Description = 'CreatedByAsset'
					);
					
					//LP-87 ----->
					try {
						delete [SELECT Id FROM Asset__c WHERE Id = :ac.ParentId];
					}
					catch(Exception e) {
						System.debug('Delete problem!');
					}
					//LP-87 <-----
				}
			}
			else if (fileIndicator) {
				tesla.Link__c = NULL;
				upsert tesla;
			}
			else {
				upsert tesla;
			}
			pr = Page.LPAssetDetail;
			pr.getParameters().put('Id', tesla.Id);
			pr.setRedirect(true);
		}
		catch (Exception e) {
			ApexPages.addMessages(e);
		}
		return pr;
	}

	public PageReference clearAttach() {
		// delete asset when "cancel" 
		Cookie createdAsset = ApexPages.currentPage().getCookies().get('CreatedAsset');

		if (createdAsset != null) {
			String createdAssetValue = createdAsset.getValue();
			if (String.isNotBlank(createdAssetValue) || createdAssetValue != 'null') {
				createdAssetValue = String.escapeSingleQuotes(createdAssetValue);
				try {
					delete [SELECT Id FROM Attachment WHERE Id = :createdAssetValue];
				} catch(Exception e) {
					System.debug('Delete problem! ' + e);
				}
			}
		}
		//LP-87 -----> Deletes Asset__c record
		Cookie assetCook = ApexPages.currentPage().getCookies().get('AssetIdToDelete');

		if (assetCook != null) {
			String cookieValue = assetCook.getValue();
			if (String.isNotBlank(cookieValue) || cookieValue != 'null') {
				String escapeCookieValue = String.escapeSingleQuotes(cookieValue);
				try {
					delete [SELECT Id FROM Asset__c WHERE Id = :escapeCookieValue];
				}
				catch(Exception e) {
					System.debug('Delete problem! ' + e);
				}
			}
		}
		/* redirects to LPAssets */
		String retURLParametr = ApexPages.currentPage().getParameters().get('retURL');
		if (String.isNotBlank(retURLParametr)) {
			PageReference pr = new PageReference(retURLParametr);
			pr.setRedirect(true);
			return pr;
		}
		PageReference pr = Page.LPAssets;
		pr.setRedirect(true);
		return pr;
		//LP-87 <-----
	}

	public void clearAttachSave() {
		clearAttachContact();
		clearAttachAsset(false);
	}

	public void clearAttachContact() {
		String contactId = [SELECT ContactId FROM User WHERE Id = :UserInfo.getUserId()][0].ContactId;
		delete [SELECT Id FROM Attachment WHERE Description = 'CreatedByAsset' AND ParentId = :contactId];
	}

	public void clearAttachAsset(Boolean cancel) {
		List<Attachment> attachToDelete;
		Attachment attachWithDescription;
		attachToDelete = [SELECT Id FROM Attachment WHERE Description = 'CreatedByAsset' AND ParentId = :tesla.Id ORDER BY CreatedDate DESC];
		if (attachToDelete.size() > 0) {
			if (!cancel && String.isBlank(linkText)) {
				attachWithDescription = attachToDelete[0];
				attachWithDescription.description = '';
				update attachWithDescription;
				attachToDelete.remove(0);
			}
			delete attachToDelete;
		}
	}

	/* displays the image for ePortfolio shareable side */
	public static String getHeroImageId() {
		return LP_Template_Settings__c.getInstance().Hero_Image__c;
	}
	public static Boolean getHasCustomHeroImage() {
		return String.isNotBlank(LP_Template_Settings__c.getInstance().Hero_Image__c);
	}

	/* called from Save & Add button on LPLearnerProfileEdit */
	public PageReference saveAndAddAsset() {
		Boolean createMode = getShowCreateAddBtn();
		PageReference pr = saveAsset();
		if (createMode && tesla.Status__c != 'Inactive') {
			Id lpParamId = Id.valueOf(ApexPages.currentPage().getParameters().get('lp'));
			insert new Asset_Learner_Profile__c(
				Asset__c = tesla.Id,
				Learner_Profile__c = lpParamId
			);
			String retURLParametr = ApexPages.currentPage().getParameters().get('retUrl');
			if (String.isBlank(retURLParametr)) {
				pr = Page.LPAssets;
				pr.getParameters().put('lp', lpParamId);
				pr.setRedirect(true);
			}
			else {
				pr = new PageReference(retURLParametr);
			}
		}
		return pr;
	}

	public void submitAddRemoveLP() {
		Set<Id> deleteAssetProfile = new Set<Id>();
		List<Asset_Learner_Profile__c> createAssetProfile = new List<Asset_Learner_Profile__c>();
		for (LPLearnerProfileController.Eliforp elItem : efp.lps) {
			if (elItem.initialyChecked != elItem.checked) {
				if (elItem.checked) {
					createAssetProfile.add(
						new Asset_Learner_Profile__c(
							Asset__c = tesla.Id,
							Learner_Profile__c = elItem.Id
						)
					);
				}
				else {
					deleteAssetProfile.add(elItem.Id);
				}
			}
		}
		if (createAssetProfile.size() > 0) {
			insert createAssetProfile;
		}
		if (deleteAssetProfile.size() > 0) {
			delete [SELECT Id FROM Asset_Learner_Profile__c WHERE Asset__c = :tesla.Id AND Learner_Profile__c IN :deleteAssetProfile];
		}
		initFromView();
	}

	public Boolean getShowMyLPbtn() {
		return SObjectType.Asset_Learner_Profile__c.isCreateable() && tesla.Status__c != 'Inactive';
	}

	public String getLearnerProfileName() {
		Id lpParamId = Id.valueOf(ApexPages.currentPage().getParameters().get('lp'));
		return getShowCreateAddBtn() ? [SELECT Name FROM Learner_Profile__c WHERE Id = :lpParamId].Name : '';
	}

	public Boolean getShowCreateAddBtn() {
		return lpMode && tesla.Id == NULL;
	}

	public List<String> getAssetLink() {
		List<String> resultList = new List<String> { '', '', 'fa-file-o' };
		if (String.isNotBlank(tesla.Link__c)) {
			resultList = new List<String> { tesla.Link__c, tesla.Link__c, 'fa-link' };
		}
		else if (tesla.NotesAndAttachments.size() > 0) {
			String[] parts = tesla.NotesAndAttachments[0].Title.split('\\.');
			String ext = parts[parts.size() - 1].toLowerCase();
			//ext = !CommunitySearchController.AWESOME_FILE_TYPES.containsKey(ext) ? 'fa-file-o' : CommunitySearchController.AWESOME_FILE_TYPES.get(ext);
			resultList = new List<String> {
				tesla.NotesAndAttachments[0].Title,
				LPUtils.checkUrl('/servlet/servlet.FileDownload?file=' + tesla.NotesAndAttachments[0].Id),
				'fa-file-o'
			};
		}
		return resultList;
	}

	public PageReference deleteAsset() {
		PageReference pr;
		try {
			delete tesla;
			pr = Page.LPAssets;
			if (lpMode) {
				pr.getParameters().put('lp', Id.valueOf(ApexPages.currentPage().getParameters().get('lp')));
			}
			pr.getParameters().put('c', tesla.Category__c);
			pr.setRedirect(true);
		}
		catch (Exception e) {
			ApexPages.addMessages(e);
		}
		return pr;
	}

	public String getDeleteConfirmMessage() {
		Boolean acdc = false;
		for (LPLearnerProfileController.Eliforp eleItem : efp.lps) {
			acdc = (eleItem.checked == true) ? true : acdc;
		}
		return acdc ? Label.LBL_Delete_Asset : Label.LBL_Delete_Asset_message;
	}

	public Boolean getInitialActiveStatus() {
		return tesla.Status__c == 'Active';
	}

	// LIST MODE 

	private Boolean listMode;
	private Boolean categoryMode;
	private final static String ALIAS_PARAM_DIVIDER = '?u=';

	public Boolean lpMode { get { return lpMode == NULL ? false : lpMode; } set; }
	public Boolean wrongProfile { get { return wrongProfile == NULL ? false : wrongProfile; } set; }
	public transient Learner_Profile__c currentLearnerProfile { get; set; }

	public void initFromList() {
		listMode = getCategoryParam() == NULL;
		categoryMode = !listMode;
		String lpParam = ApexPages.currentPage().getParameters().get('lp');
		lpMode = String.isNotBlank(lpParam);
		currentLearnerProfile = new Learner_Profile__c();
		if (lpMode) {
			String escapedParam = String.escapeSingleQuotes(lpParam);
			List<Learner_Profile__c> checkLPlist = [
				SELECT Id, Status__c, Name, Description__c
				FROM Learner_Profile__c
				WHERE Id = :String.escapeSingleQuotes(lpParam)
					AND OwnerId = :UserInfo.getUserId()
			];
			wrongProfile = checkLPlist.size() == 0;
			currentLearnerProfile = wrongProfile ? new Learner_Profile__c() : checkLPlist[0];
		}
		
	}

	public Boolean getInactiveProfile() {
		Set<String> activeProfileSet = new Set<String> { 'Active', 'Draft' };
		return lpMode && !activeProfileSet.contains(currentLearnerProfile.Status__c);
	}

	public String getLPStatusColorStyle() {
		Map<String, String> tm = new Map<String, String> { 'Active' => 'text-success', 'Draft' => 'text-warning', 'Inactive' => 'text-danger' };
		return tm.get(currentLearnerProfile.Status__c);
	}

	public String getLearnerProfilePageLink() {
		return LPLearnerProfileController.BASE_LP_LINK + currentLearnerProfile.Id;
	}

	public Boolean getShowLPbtns() {
		return lpMode && !categoryMode;
	}

	public Boolean getAddFromCategoryBtn() {
		return lpMode && categoryMode && SObjectType.Asset_Learner_Profile__c.isCreateable();
	}

	public String getUrlForAddFromCategory() {
		return prepareUrl(Page.LPMyAssets.getUrl()) + addCategoryLPParam('?');
	}

	public String getUrlForNewAsset() {
		return prepareUrl(Page.LPAssetEdit.getUrl())
				+ '?retURL=' + EncodingUtil.urlEncode(prepareUrl(Page.LPAssets.getUrl() + addCategoryLPParam('?')), 'UTF-8')
				+ addCategoryLPParam('&');
	}

	public String getUrlForEditAsset() {
		return prepareUrl(Page.LPAssetEdit.getUrl())
				+ '?id=' + tesla.Id
				+ '&retURL=' + EncodingUtil.urlEncode(prepareUrl(Page.LPAssetDetail.getUrl()) + '?id=' + tesla.Id, 'UTF-8');
	}

	public String getUrlForEditLearnerProfile() {
		String lpId = ApexPages.currentPage().getParameters().get('lp');
		return prepareUrl(Page.LPLearnerProfileEdit.getUrl())
				+ '?id=' + lpId
				+ '&retURL=' + EncodingUtil.urlEncode(prepareUrl(Page.LPAssets.getUrl()) + '?lp=' + lpId, 'UTF-8');
	}

	public String getLearnerProfileLink() {
		return lpMode ? ('&lp=' + String.escapeSingleQuotes(ApexPages.currentPage().getParameters().get('lp'))) : '';
	}

	private static String prepareUrl(String inUncouthUrl) {
		return inUncouthUrl.replace('/apex/', Site.getPathPrefix() + '/');
	}

	private String addCategoryLPParam(String inGlue) {
		String result = '';
		String cp = ApexPages.currentPage().getParameters().get('c');
		if (String.isNotBlank(cp)) {
			result += inGlue +'c=' + EncodingUtil.urlEncode(cp, 'UTF-8');
			inGlue = '&';
		}
		String lpp = ApexPages.currentPage().getParameters().get('lp');
		if (String.isNotBlank(lpp)) {
			result += inGlue +'lp=' + lpp;
		}
		return result;
	}

	public List<Yrogetac> getCategories() {
		List<Yrogetac> resultList = new List<Yrogetac>();
		if (listMode == true && !wrongProfile) {
			String yQuery = 'SELECT COUNT(Id) Counter, Category__c Cat FROM Asset__c WHERE User__c =\'' + UserInfo.getUserId() + '\'';
			if (lpMode) {
				yQuery += ' AND Id IN (SELECT Asset__c FROM Asset_Learner_Profile__c WHERE Learner_Profile__c = \'';
				yQuery += String.escapeSingleQuotes(ApexPages.currentPage().getParameters().get('lp')) + '\')';
			}
			yQuery += 'GROUP BY Category__c ORDER BY Category__c';
			Map<String, Yrogetac> filledCategoriesMap = new Map<String, Yrogetac>();
			for (AggregateResult arItem : Database.query(yQuery)) {
				String tc = (String)arItem.get('Cat');
				filledCategoriesMap.put((String.isBlank(tc) ? 'none' : tc.toLowerCase()), new Yrogetac(arItem));
			}
			for (Schema.PicklistEntry pe : SObjectType.Asset__c.fields.Category__c.getPicklistValues()) {
				String tc2 = pe.getValue().toLowerCase();
				resultList.add(filledCategoriesMap.containsKey(tc2) ? filledCategoriesMap.get(tc2) : new Yrogetac(pe.getValue()));
			}
		}
		return resultList;
	}

	public List<Tessa> getAssets() {
		List<Tessa> resultList = new List<Tessa>();
		if (categoryMode == true && !wrongProfile) {
			String aQuery = 'SELECT Id, Name, Link__c, Description__c, Type__c, Status__c, CreatedDate, (SELECT Id, Name, BodyLength FROM Attachments ORDER BY CreatedDate DESC LIMIT 1)';
			aQuery += ' FROM Asset__c WHERE Category__c = \'' + String.escapeSingleQuotes(ApexPages.currentPage().getParameters().get('c')) + '\'';
			aQuery += ' AND User__c =\'' + UserInfo.getUserId() + '\'';
			if (lpMode) {
				aQuery += ' AND Id IN (SELECT Asset__c FROM Asset_Learner_Profile__c WHERE Learner_Profile__c = \'';
				aQuery += String.escapeSingleQuotes(ApexPages.currentPage().getParameters().get('lp')) + '\')';
			}
			for (Asset__c aItem : Database.query(aQuery)) {
				resultList.add(new Tessa(aItem));
			}
		}
		return resultList;
	}

	private static Map<String, String> AWESOME_FILE_TYPES = new Map<String, String> {
		'link' => 'fa-link', 'xls' => 'fa-file-excel-o', 'xlsx' => 'fa-file-excel-o', 'pdf' => 'fa-file-pdf-o',
		'doc' => 'fa-file-word-o', 'docx' => 'fa-file-word-o', 'ppt' => 'fa-file-pdf-o', 'pptx' => 'fa-file-pdf-o',
		'txt' => 'fa-file-text-o', 'png' => 'fa-file-image-o', 'gif' => 'fa-file-image-o', 'jpeg' => 'fa-file-image-o',
		'jpg' => 'fa-file-image-o', 'bmp' => 'fa-file-image-o'
	};

	// PAGE MODE

	public Boolean portfolioFound { get; set; }
	public String portfolioOwnerName { get; set; }
	public String portfolioDescription { get; set; }

	public void initFromPage() {
		try {
			Id lpParamId = Id.valueOf(ApexPages.currentPage().getParameters().get('lp'));
			Learner_Profile__c checklp = [
				SELECT Id, Description__c, Owner.Id, Owner.Name
				FROM Learner_Profile__c
				WHERE Id = :lpParamId
					AND (Status__c = 'Active' OR (Status__c = 'Draft' AND OwnerId = :UserInfo.getUserId()))
			];

			List<User> uList = [
				SELECT Id, Contact.Id, Contact.FirstName, Contact.LastName
				FROM User
				WHERE Id = :checklp.Owner.Id
					AND ContactId != null
			];
			portfolioOwnerName = uList.isEmpty() ? checklp.Owner.Name : uList[0].Contact.FirstName + ' ' + uList[0].Contact.LastName;
			portfolioDescription = checklp.Description__c;
			portfolioFound = true;
		}
		catch (Exception e) {
			portfolioFound = false;
		}
	}

	/* grabs all the populated Categories for a particular ePortfolio */
	public List<Yrogetac> getCategoriesWithAssets() {
		List<Yrogetac> resultList = new List<Yrogetac>();
		if (portfolioFound) {
			Map<String, Yrogetac> assemblyCategoryMap = new Map<String, Yrogetac>();
			Id lpParamId = Id.valueOf(ApexPages.currentPage().getParameters().get('lp'));
			for (Asset__c aItem : [
						SELECT Id, Name, Link__c, Description__c, Type__c, Status__c, Category__c, CreatedDate,
							(SELECT Id, Name, BodyLength FROM Attachments ORDER BY CreatedDate DESC LIMIT 1)
						FROM Asset__c
						WHERE Id IN (SELECT Asset__c FROM Asset_Learner_Profile__c WHERE Learner_Profile__c = :lpParamId)
				]) {

				String catUnique = String.isBlank(aItem.Category__c) ? 'none' : aItem.Category__c;
				catUnique = catUnique.replace(' ', '').toLowerCase();
				if (!assemblyCategoryMap.containsKey(catUnique)) {
					assemblyCategoryMap.put(catUnique, new Yrogetac(aItem.Category__c, catUnique));
				}
				assemblyCategoryMap.get(catUnique).assets.add(new Tessa(aItem));
			}
			for (Schema.PicklistEntry pe : SObjectType.Asset__c.fields.Category__c.getPicklistValues()) {
				String tc3 = pe.getValue().replace(' ','').toLowerCase();
				if (assemblyCategoryMap.containsKey(tc3)) {
					resultList.add(assemblyCategoryMap.get(tc3));
				}
			}
		}
		return resultList;
	}

	public String getLogoUrl() {
		LP_Template_Settings__c lpts = LP_Template_Settings__c.getOrgDefaults();
		return (lpts == NULL || String.isBlank(lpts.Header_Logo__c)) ? NULL : lpts.Header_Logo__c;
	}

	public PageReference getSiteTemplatePage() {
		return LPUtils.getSiteTemplatePage();
	}

	// WRAPPER CLASSES
	/* grabs Asset__c records for display on Category pages */
	public class Tessa {
		public String id { get; set; }
		public String name { get; set; }
		public String atype { get; set; }
		public String link { get; set; }
		public String description { get; set; }
		public String icon { get; set; }
		public String size { get; set; }
		public String file { get; set; }
		public String status { get; set; }
		public String dshot { get; set; }

		public Tessa(Asset__c ina) {
			id = ina.Id;
			name = ina.Name;
			atype = ina.Type__c;
			description = ina.Description__c;
			dshot = String.isBlank(description) ? '' : description.abbreviate(32);
			file = ina.Status__c == 'Inactive' ? 'f-txt' : 'f-docx';
			status = ina.Status__c;
			if (String.isNotBlank(ina.Link__c)) {
				icon = 'fa-link';
				link = ina.Link__c;
			}
			else if (ina.Attachments.size() > 0) {
				String[] parts = ina.Attachments[0].Name.split('\\.');
				String ext = parts[parts.size() - 1].toLowerCase();
				icon = !AWESOME_FILE_TYPES.containsKey(ext) ? 'fa-file-o' : AWESOME_FILE_TYPES.get(ext);
				size = LPUtils.convertFileSize(ina.Attachments[0].BodyLength);
				link = LPUtils.checkUrl('/servlet/servlet.FileDownload?file=' + ina.Attachments[0].Id);
			}
			else {
				link = '#';
				icon = 'fa-file-o';
			}
		}
	}

	/* grabs lists from above to display count */
	public class Yrogetac {
		public String name { get; set; }
		public Integer counter { get; set; }
		public List<Tessa> assets { get; set; }
		public String catid { get; set; }

		public Yrogetac(AggregateResult inar) {
			name = (String)inar.get('Cat');
			counter = (Integer)inar.get('Counter');
		}

		public Yrogetac(String inc) {
			name = inc;
			counter = 0;
		}

		public Yrogetac(String inc, String inid) {
			name = inc;
			catid = inid;
			assets = new List<Tessa>();
		}

		public String getItemString() {
			List<String> parts = Label.LBL_Item_Items.split(';');
			String single = parts[0];
			String plural = parts.size() > 1 ? parts[1] : parts[0];
			return String.valueOf(counter) + ' ' + (counter == 1 ? single : plural);
		}
	}

}

And here the snippet of the page: 
<!-- START LIST VIEW -->
					<div class="view" id="list">
						<div class="panel panel-default">
							<div class="panel-body">
								<div class="row">
									<div class="col-lg-2">
									<div class="form-group">
										<input type="text" class="form-control input-sm form-control-flat" placeholder="{!$Label.LBL_Search_Asset}" onkeyup="checksearch(this);"/>
									</div>
									</div>
								</div>
								<apex:form id="tableAssets">
									<table id="basic-datatable" class="table table-bordered">
										<thead>
											<tr>
												<th id="first-th" class="click-header" onclick="toogleall(this);"><i class="fa fa-plus-square-o" title="{!$Label.LBL_Show_Hide_All}"></i></th>
												<th width="60%">{!$ObjectType.Asset__c.Fields.Name.Label}</th>
												<th>{!$ObjectType.Asset__c.Fields.LastModifiedDate.Label}</th>
											</tr>
										</thead>
										<apex:variable var="index" value="{!0}" />
											<tbody>
												<apex:repeat value="{!Categories}" var="c">
													<tr class="category-row" id="{!c.name}" onclick="togglerows(this);">
														<td class="hidden"><label></label></td>
														<td colspan="3"><i class="fa fa-plus-square-o"></i>&nbsp;&nbsp;
															<a href="{!$Page.LPAssets}?c={!URLENCODE(c.name)}{!LearnerProfileLink}" title="{!c.name}" class="folders">
																<span class="name">{!c.name}</span>
															</a>
														</td>
														<td class="hidden"><span></span></td>
													</tr>
												<apex:repeat value="{!Assets}" var="a">
													<tr id="{!index}{!c.name}" class="category-in" style="display:none;">
														<td class="asset-name"><span>
														<a href="{!$Page.LPAssetDetail}?id={!a.id}" title="{!a.status}">
															<span class="icon file {!a.file}"><i class="fa {!a.icon}"></i></span>
															<span class="name">{!a.name}</span>
															<apex:outputPanel styleClass="details" rendered="{!!ISBLANK(a.size)}">{!a.size}</apex:outputPanel>
														</a>
														</span></td>
														<!-- <td><span>{!ca.lmdate}</span></td> -->
													</tr>
												<apex:variable var="index" value="{!index+1}" />
												</apex:repeat>
												</apex:repeat>
											</tbody>
									</table>
								</apex:form>
							</div>
						</div>
					</div>
					<!-- END LIST VIEW -->

 
I've got a strange error. I grabbed the controller code from this blog post, but when I try to save it to my dev org, I get an error: unexpected token: '='. I can't seem to figure out why. Any help would be appreciated!

Here's the controller throwing the error:
Public class ThumnailController {

  public String imageUrl {get; set;}

  ContentVersion[] cvs = [select id from contentversion where contentdocumentid= '0691a0000015c3v' and isLatest=true];

  imageUrl ='/sfc/servlet.shepherd/version/renditionDownload?rendition=THUMB720BY480&versionId=' + cvs[0].id;

}

The error is being thrown at this line:
imageUrl ='/sfc/servlet.shepherd/version/renditionDownload?rendition=THUMB720BY480&versionId=' + cvs[0].id;


 
I have added several new VF pages and their controllers to a managed package. When I deploy the managed package, I am unable to change the security to the controllers. Can't grant permission from profiles and no 'Security' link appears next to the classes. They are properly assigned in my packaging org. 

Any thoughts on what's happening? Thanks in advance.
I am trying to deploy a GitHub repo through Eclipse into a sandbox. One of the custom objects throws the above error. What can I do to prevent this?
My organization and our development partner recently parted ways. The partner gave us access to the GitHub repository, but I am having difficulty deploying it to our sandbox. I get a bunch of errors about certain objects and fields not existing though I see them in the package. The sandbox contains the managed package that they had provided us. Do we need to delete the managed package to install the GitHub repo? 

In production, we have about 1500 users using this package, so I'm really hoping I don't have to export everything, delete the package, reinstall, and import everything again. Any guidance would be deeply appreciated.
Hello,

I am deploying a change set to production and it won't pass validation. I had no issue deploying to other sandboxes. Here are the errors: User-added image
varCaseID is definitely referenced in the flow. Any thoughts as to what might be causing the issue?
 
Hello,

Most of our community users self-register, but we will soon be creating users via integration. I am creating a welcome/set password email for the integration-created users, but am having difficulty with the link for users to create passwords. If I'm reading the documentation correctly, the {!Community_URL} and {!$Network.NetworkUrlForUserEmails} won't work unless the email is set as the Community default Welcome email. 

Any thoughts on how to remedy this situation?
Hello,

I have a batch class for converting Contacts into Community Users. My test class keeps failing and I can't seem to get more than 37% coverage. The error I get from the failed tests is:
Error Message: System.NullPointerException: Attempt to de-reference a null object
Stack Trace: Class.ConvertToCommUsers.execute: line 23, column 1
Class.TestConvertTOCommUsers.test: line 20, column 1
Any help would be greatly appreciated!

The class
global class ConvertToCommUsers implements Database.Batchable<sObject> {
	global String query;   
    	global Database.QueryLocator start(Database.BatchableContext BC){
        	query = 'SELECT	Id, FirstName, LastName, Name, Email, AccountId FROM Contact WHERE RecordType.Name = \'Learner\' AND Id NOT IN (SELECT ContactId FROM User)'; 
        
        	return Database.getQueryLocator(query);
    }
    
    global void execute(Database.BatchableContext BC, List<Contact> scope){
        String Passwd;
        Profile LPCommPf = [SELECT Id, Name FROM Profile WHERE Name = 'Learner Profile Community User' LIMIT 1];
        List<Messaging.SingleEmailMessage> setPWs = new List<Messaging.SingleEmailMessage>();
        List<User> learners = new List<User>();
        
        for (Contact c : scope){
           User u = new User();
            	u.FirstName = c.FirstName;
                u.LastName = c.LastName;
                u.ContactId = c.Id;
                u.Email = c.Email;
                u.Username = c.Email;
                u.CommunityNickname = c.Email.Trim().toLowerCase();
                u.Alias = c.Name.abbreviate(8);
                u.ProfileId = LPCommPf.id;
                u.LocaleSidKey = 'en_US';
                u.TimeZoneSidKey = 'America/New_York';
                u.LanguageLocaleKey = 'en_US';
                u.EmailEncodingKey = 'UTF-8';
                String pwd = Passwd;
            
            learners.add(u);
        } 
            
        	insert learners;
        
        for( User s : learners){
            
            Messaging.SingleEmailMessage setPW = new Messaging.SingleEmailMessage();
        	List<String> sendTo = new List<String>();
        	sendTo.add(s.Email);
        	setPW.setToAddresses(sendTo);
        	setPW.setSenderDisplayName('info@digitalonramps.com');
        	setPW.setSenderDisplayName('Digital On-Ramps');
        	setPW.setTemplateId('00X17000000E35e'); 
        	setPW.setTargetObjectId(s.Id);
        	setPW.setSaveAsActivity(false);
            
            setPWs.add(setPW);
            
        }
        Messaging.sendEmail(setPWs);
    }
    
    global void finish(Database.BatchableContext BC){
        Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
        mail.setToAddresses(new String[] {'meg372@drexel.edu'});
        	mail.setReplyTo('batch@digitalonramps.com');
        	mail.setSenderDisplayName('Batch Processing');
        	mail.setSubject('Batch Process Complete');
        	mail.setPlainTextBody('Batch Process has completed');
        
        Messaging.sendEmail(new Messaging.SingleEmailMessage[] {mail});
        
    }

}

The test class
@isTest
private class TestConvertToCommUsers {
    static testmethod void test(){
        Database.QueryLocator QL;
        Database.BatchableContext BC;
        List<Contact> scope = new List<Contact>();
        
            Contact c = new Contact(FirstName= 'Test', LastName = 'Test', Email='testtest@dor.com',  RecordTypeId = '012G0000001QJQc');
            scope.add(c);
        
        	insert scope;
        	 
    
    
        Test.startTest();
         
        ConvertToCommUsers comm = new ConvertToCommUsers();
       	comm.query = 'SELECT Id, FirstName, LastName, Name, Email, AccountId FROM Contact';
        QL = comm.start(BC);
        comm.execute(BC, scope);
        comm.finish(BC);

        Test.stopTest();       
    }
}




Thanks in advance!
Liz
We have partnered with a new organization and have the potential to have 20000 new customer community users request access over the next 2 months. We have been using self registration, but for this partnership, we don't want to have people duplicating efforts. We have set up a connection where the partner will send us users' data via SFTP and we will use Jitterbit to insert that into Salesforce as Contacts. My problem comes from creating Customer Community Users from those Contacts. You can't create users via workflow and this needs to go live on April 1.

Any thoughts? 
I can't save a flow I'm working on. I get an error and when I check the logs all it gives me is "Error #1009". Has anyone encountered this? 
I try to save a specific flow and receive the following error: "We're sorry, but a serious error occurred. Please don't close the Cloud Flow Designer window. Contact Salesforce Customer Support as soon as possible."

I tried submitting a case, considering the "Contact Salesforce Customer Support as soon as possible." and was told that because we don't have Premier Support to post here. Any thoughts? It only happens on one flow. The others save without issue.
Hello, I am working on writing a test class for a custom controller that creates an Account list, and then based on the selected Account's ID, redirects to a new page. I'm new to this so any help would be appreciated. 
Controller:
public without sharing class SDPController {
    public List<Account> PAISchools = new List<Account>();
    public SDPController(){   
    }

    public List<SelectOption> PAIList{
        get{
            PAISchools = [Select Account.Name, Account.Id From Account Where Account.ParentId = '0011700000BZkKR'];
            
            PAIList = new List<SelectOption>();
            
            for(Account temp : PAISchools){
                PAIList.add(new SelectOption(temp.id, temp.Name));
            }
            return PAIList;
        }
        set;    
    }
    
    public String idString{get;set;}
    
    
	public PageReference saveform(){
  		update PAISchools ; // helps in saving the record
  			PageReference pageRef = new PageReference('https://dev2-dor.cs22.force.com/eportfolio/LPRegistration?code='+idString+'');
            	pageRef.setRedirect(true);
            	return pageRef;
	}
    
    public PageReference signin(){
        PageReference signIn = new PageReference('https://dev2-dor.cs22.force.com/eportfolio/motivislp__LPSignIn');
        signIn.setRedirect(true);
        return signIn;
    }
  
        
}

Test class:
@isTest
public class TestSDPController {
    
    public static testMethod void testSDP() {  
       
       Account acc = new Account(name= 'Testing', ParentId= '0011700000BZkKR');
        insert acc;
       
       Test.startTest();
       PageReference testPage = Page.SchoolSelect2;
        Test.setCurrentPage(testPage);
        testPage.getUrl();
        
        SDPController sdp = new SDPController();
        	sdp.saveform();
        Test.stopTest();
        
              
     }

}

Am I at least on the right path?
I am creating a VF page where students will choose their school from a dropdown list and then based on the selection, proceed to a registration page specific to that school. I am creating the list, grabbing the Name and ID, in a custom controller. I've the the dropdown working, but I'm stuck on how to get the ID once the school is selected and appending it to a URL so that the students are directed to the right page. Any thoughts?

My code for reference:
VF page:
<apex:page showHeader="false" sideBar="false" standardStylesheets="false" docType="html-5.0" applyBodyTag="false" applyHtmlTag="false" controller="SDPController">
    <script>
    
	</script>
<apex:composition template="{!$Site.Template}">
    <apex:define name="title">{!$Label.LBL_Page_Title}</apex:define>
    <apex:define name="body">
    <div class="container">
        <div align="center" style="font-size:20px;">
        <p>Welcome to the Digital On-Ramps ePortfolio! Please select you school and click "Next."</p>
        <apex:form >
        	<apex:selectList multiselect="false" size="1"  required="false" style="font-size:20px;">
            	<apex:selectOptions value="{!PAIList}" />
            </apex:selectList>
            <div class="modal-footer">
            <apex:commandButton id="register" value="Next" />
        </div>
        </apex:form>
        </div>
        
    </div>
    </apex:define>
</apex:composition>   
</apex:page>

And controller:
public without sharing class SDPController {
    public List<Account> PAISchools = new List<Account>();
    public SDPController(){
        
    }

    public List<SelectOption> PAIList{
        get{
            PAISchools = [Select Account.Name, Account.Id From Account Where Account.ParentId = '0011700000BZkKR'];
            
            PAIList = new List<SelectOption>();
            
            for(Account temp : PAISchools){
                PAIList.add(new SelectOption(temp.id, temp.Name));
            }
            return PAIList;
        }
        set;    
    }
  
        
}

 
Hello,

I have created a flow whereby visitors to our community center can sign in and register for the programs they are attending. We are going to start collecting demographics data soon, and as a result, I am encountering the error in the heading: UPDATE --- UPDATE FAILED --- ERRORS : (CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY) entity type cannot be updated: Contact, 

The flow is displayed through a site and the visitor views the site as a guest user. Checking the guest user profile, I found that I cannot allow the guest user to edit standard sObject records and I believe this is what is causing the issue. Any thoughts on a work around?
Hello,

I created a flow to check people in at a community center. It has been functioning fine until yesterday when I started getting an error: "INSERT --- INSERT FAILED --- ERRORS : (CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY) entity type cannot be inserted: Campaign Member,"

The flow is displayed through a Visualforce page in a site. The error is only thrown when the flow is run through the page or site. No edits have been made to the page or site in the past week, so I'm not sure what caused this error. It's no longer happening, but I'd like to get to the bottom of this.

Any thoughts?
Hello,

I am working on writing a test class for an email trigger. The trigger fires when a Community user self-registers. I'm struggling to get the test class to test this though. 

Here's the trigger:
trigger LearnerWelcomeEmail on Contact (after insert) {
    
    //Prepare to send welcome emails
    List<Messaging.SingleEmailMessage> welcome = new List<Messaging.SingleEmailMessage>();
    
    for (Contact learner : Trigger.New){
        if(trigger.isInsert && learner.Self_Registered__c == true)
        {
           Messaging.SingleEmailMessage learnerEmail = new Messaging.SingleEmailMessage();
                List<String> sendTo = new List<String>();
                sendTo.add(learner.Email);
                learnerEmail.setToAddresses(sendTo);
                learnerEmail.setReplyTo('info@digitalonramps.com');
                learnerEmail.setSenderDisplayName('Digital On-Ramps');
                learnerEmail.setTemplateId('00X17000000DnrL');
                learnerEmail.setTargetObjectId(learner.Id);

            
            welcome.add(learnerEmail);
            }
    }
    if(welcome.size()>0){
        Messaging.sendEmail(welcome);
    }
}

And here's the test class I have:
@isTest public class TestLearnerWelcome {
    @isTest public static void emailUser(){
        Id p = [SELECT id FROM Profile WHERE name = 'Learner Profile Community User'].id;
        
        Account acct = new Account(name= 'TestAcct');
        insert acct;
        
        Contact con = new Contact(LastName = 'Learner', AccountId = acct.Id, email = 'learner@test.edu');
        insert con;
        
        User u = new User(alias = 'learner1', email = 'learner@test.edu', emailencodingkey='UTF-8', lastname='Learner', languagelocalekey='en_US',
                localesidkey='en_US', profileid = p, country='United States',IsActive =true,
                ContactId = con.Id,
                timezonesidkey='America/Los_Angeles', username='tester@noemail.com');
        insert u;
        
                
        System.runAs(u){
 
        }

        
    }

}

I currently have 28% coverage. Any insight would be greatly appreciated!
I've got a strange error. I grabbed the controller code from this blog post, but when I try to save it to my dev org, I get an error: unexpected token: '='. I can't seem to figure out why. Any help would be appreciated!

Here's the controller throwing the error:
Public class ThumnailController {

  public String imageUrl {get; set;}

  ContentVersion[] cvs = [select id from contentversion where contentdocumentid= '0691a0000015c3v' and isLatest=true];

  imageUrl ='/sfc/servlet.shepherd/version/renditionDownload?rendition=THUMB720BY480&versionId=' + cvs[0].id;

}

The error is being thrown at this line:
imageUrl ='/sfc/servlet.shepherd/version/renditionDownload?rendition=THUMB720BY480&versionId=' + cvs[0].id;


 
I try to save a specific flow and receive the following error: "We're sorry, but a serious error occurred. Please don't close the Cloud Flow Designer window. Contact Salesforce Customer Support as soon as possible."

I tried submitting a case, considering the "Contact Salesforce Customer Support as soon as possible." and was told that because we don't have Premier Support to post here. Any thoughts? It only happens on one flow. The others save without issue.
Hello,

We have clients upload documents, images, ppt, pdfs, etc and link to google docs, videos, websites, etc as attachments to a custom object in our Customer Community and we want to display thumbnails of these assets. 

Anyone have thoughts on how to accomplish this? I've found ways to display the images as thumbnails, but am confounded by how to display the variety of file types and links. 

Thanks in advance!
Hi everyone, I'm a Certified Administrator perusing a MBA in Business Intelligence. I'm looking for contract work in the Philadelphia area or remote work. I have experience configuring an organization to fit a company's business objectives. I have trained numerous sales engineers for a manufacturing company, and also created a roadmap to properly implement Salesforce. I also have a background in the financial service industry. 

 
I am trying to create a table that displays Asset__c records grouped by a picklist field, Category__c. I've got the table displaying the Categories, but cannot get the Assets to display. Here's what is looks like now: User-added image
Here's the code I've got so far:
Class
public with sharing class ListViewController {
	
	public List<String> categories {get; set;}
	public List<Asset__c> tessa {get; set;}
	
	public ListViewController(){
		categories = new List<String>();
		Schema.DescribeFieldResult fieldResult = Asset__c.Category__c.getDescribe();
		System.debug(fieldResult);
		List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues();
		System.debug('--ple-->> ' + ple);
		for(Schema.PicklistEntry f : ple){
			categories.add(f.getLabel());
		}
		tessa = [select Name, Category__c, LastModifiedDate from Asset__c];
	
	}
         
}

Table
<div class="view" id="list">
	<div class="panel panel-default">
		<div class="panel-body">
			<div class="row">
				<div class="col-lg-2">
				<div class="form-group">
					<input type="text" class="form-control input-sm form-control-flat" placeholder="{!$Label.LBL_Search_Asset}" onkeyup="checksearch(this);"/>
				</div>
				</div>
			</div>
			<apex:form id="tableAssets">
				<table id="basic-datatable" class="table table-bordered">
					<thead>
						<tr>
							<th id="first-th" class="click-header" onclick="toogleall(this);"><i class="fa fa-plus-square-o" title="{!$Label.LBL_Show_Hide_All}"></i></th>
							<th width="60%">{!$ObjectType.Asset__c.Fields.Name.Label}</th>
							<th>{!$ObjectType.Asset__c.Fields.LastModifiedDate.Label}</th>
						</tr>
					</thead>
					<tbody>
						<apex:variable var="index" value="{!0}" />
						<apex:repeat value="{!categories}" var="cat">
							<tr class="category-row" id="{!cat}" onclick="togglerows(this);">
								<td class="hidden"><label></label></td>
								<td colspan="3"><i class="fa fa-plus-square-o"></i>&nbsp;&nbsp;<span class="name">{!cat}</span></td>
								<td class="hidden"><span></span></td>
							</tr>
							<apex:repeat value="{!tessa}" var="a">
									<tr class="category-in" style="display:none;">
										<td class="asset-name"><span>{!a.Name}</span></td>
									</tr>
								<apex:variable var="index" value="{!index+1}" />
							</apex:repeat>
						</apex:repeat>
					</tbody>
				</table>
			</apex:form>
		</div>
	</div>
</div>


       
 
I've got a strange error. I grabbed the controller code from this blog post, but when I try to save it to my dev org, I get an error: unexpected token: '='. I can't seem to figure out why. Any help would be appreciated!

Here's the controller throwing the error:
Public class ThumnailController {

  public String imageUrl {get; set;}

  ContentVersion[] cvs = [select id from contentversion where contentdocumentid= '0691a0000015c3v' and isLatest=true];

  imageUrl ='/sfc/servlet.shepherd/version/renditionDownload?rendition=THUMB720BY480&versionId=' + cvs[0].id;

}

The error is being thrown at this line:
imageUrl ='/sfc/servlet.shepherd/version/renditionDownload?rendition=THUMB720BY480&versionId=' + cvs[0].id;


 
I have added several new VF pages and their controllers to a managed package. When I deploy the managed package, I am unable to change the security to the controllers. Can't grant permission from profiles and no 'Security' link appears next to the classes. They are properly assigned in my packaging org. 

Any thoughts on what's happening? Thanks in advance.
I am trying to deploy a GitHub repo through Eclipse into a sandbox. One of the custom objects throws the above error. What can I do to prevent this?
Hello,

I am deploying a change set to production and it won't pass validation. I had no issue deploying to other sandboxes. Here are the errors: User-added image
varCaseID is definitely referenced in the flow. Any thoughts as to what might be causing the issue?
 
Hello,

I have a batch class for converting Contacts into Community Users. My test class keeps failing and I can't seem to get more than 37% coverage. The error I get from the failed tests is:
Error Message: System.NullPointerException: Attempt to de-reference a null object
Stack Trace: Class.ConvertToCommUsers.execute: line 23, column 1
Class.TestConvertTOCommUsers.test: line 20, column 1
Any help would be greatly appreciated!

The class
global class ConvertToCommUsers implements Database.Batchable<sObject> {
	global String query;   
    	global Database.QueryLocator start(Database.BatchableContext BC){
        	query = 'SELECT	Id, FirstName, LastName, Name, Email, AccountId FROM Contact WHERE RecordType.Name = \'Learner\' AND Id NOT IN (SELECT ContactId FROM User)'; 
        
        	return Database.getQueryLocator(query);
    }
    
    global void execute(Database.BatchableContext BC, List<Contact> scope){
        String Passwd;
        Profile LPCommPf = [SELECT Id, Name FROM Profile WHERE Name = 'Learner Profile Community User' LIMIT 1];
        List<Messaging.SingleEmailMessage> setPWs = new List<Messaging.SingleEmailMessage>();
        List<User> learners = new List<User>();
        
        for (Contact c : scope){
           User u = new User();
            	u.FirstName = c.FirstName;
                u.LastName = c.LastName;
                u.ContactId = c.Id;
                u.Email = c.Email;
                u.Username = c.Email;
                u.CommunityNickname = c.Email.Trim().toLowerCase();
                u.Alias = c.Name.abbreviate(8);
                u.ProfileId = LPCommPf.id;
                u.LocaleSidKey = 'en_US';
                u.TimeZoneSidKey = 'America/New_York';
                u.LanguageLocaleKey = 'en_US';
                u.EmailEncodingKey = 'UTF-8';
                String pwd = Passwd;
            
            learners.add(u);
        } 
            
        	insert learners;
        
        for( User s : learners){
            
            Messaging.SingleEmailMessage setPW = new Messaging.SingleEmailMessage();
        	List<String> sendTo = new List<String>();
        	sendTo.add(s.Email);
        	setPW.setToAddresses(sendTo);
        	setPW.setSenderDisplayName('info@digitalonramps.com');
        	setPW.setSenderDisplayName('Digital On-Ramps');
        	setPW.setTemplateId('00X17000000E35e'); 
        	setPW.setTargetObjectId(s.Id);
        	setPW.setSaveAsActivity(false);
            
            setPWs.add(setPW);
            
        }
        Messaging.sendEmail(setPWs);
    }
    
    global void finish(Database.BatchableContext BC){
        Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
        mail.setToAddresses(new String[] {'meg372@drexel.edu'});
        	mail.setReplyTo('batch@digitalonramps.com');
        	mail.setSenderDisplayName('Batch Processing');
        	mail.setSubject('Batch Process Complete');
        	mail.setPlainTextBody('Batch Process has completed');
        
        Messaging.sendEmail(new Messaging.SingleEmailMessage[] {mail});
        
    }

}

The test class
@isTest
private class TestConvertToCommUsers {
    static testmethod void test(){
        Database.QueryLocator QL;
        Database.BatchableContext BC;
        List<Contact> scope = new List<Contact>();
        
            Contact c = new Contact(FirstName= 'Test', LastName = 'Test', Email='testtest@dor.com',  RecordTypeId = '012G0000001QJQc');
            scope.add(c);
        
        	insert scope;
        	 
    
    
        Test.startTest();
         
        ConvertToCommUsers comm = new ConvertToCommUsers();
       	comm.query = 'SELECT Id, FirstName, LastName, Name, Email, AccountId FROM Contact';
        QL = comm.start(BC);
        comm.execute(BC, scope);
        comm.finish(BC);

        Test.stopTest();       
    }
}




Thanks in advance!
Liz
We have partnered with a new organization and have the potential to have 20000 new customer community users request access over the next 2 months. We have been using self registration, but for this partnership, we don't want to have people duplicating efforts. We have set up a connection where the partner will send us users' data via SFTP and we will use Jitterbit to insert that into Salesforce as Contacts. My problem comes from creating Customer Community Users from those Contacts. You can't create users via workflow and this needs to go live on April 1.

Any thoughts? 
Hello, I am working on writing a test class for a custom controller that creates an Account list, and then based on the selected Account's ID, redirects to a new page. I'm new to this so any help would be appreciated. 
Controller:
public without sharing class SDPController {
    public List<Account> PAISchools = new List<Account>();
    public SDPController(){   
    }

    public List<SelectOption> PAIList{
        get{
            PAISchools = [Select Account.Name, Account.Id From Account Where Account.ParentId = '0011700000BZkKR'];
            
            PAIList = new List<SelectOption>();
            
            for(Account temp : PAISchools){
                PAIList.add(new SelectOption(temp.id, temp.Name));
            }
            return PAIList;
        }
        set;    
    }
    
    public String idString{get;set;}
    
    
	public PageReference saveform(){
  		update PAISchools ; // helps in saving the record
  			PageReference pageRef = new PageReference('https://dev2-dor.cs22.force.com/eportfolio/LPRegistration?code='+idString+'');
            	pageRef.setRedirect(true);
            	return pageRef;
	}
    
    public PageReference signin(){
        PageReference signIn = new PageReference('https://dev2-dor.cs22.force.com/eportfolio/motivislp__LPSignIn');
        signIn.setRedirect(true);
        return signIn;
    }
  
        
}

Test class:
@isTest
public class TestSDPController {
    
    public static testMethod void testSDP() {  
       
       Account acc = new Account(name= 'Testing', ParentId= '0011700000BZkKR');
        insert acc;
       
       Test.startTest();
       PageReference testPage = Page.SchoolSelect2;
        Test.setCurrentPage(testPage);
        testPage.getUrl();
        
        SDPController sdp = new SDPController();
        	sdp.saveform();
        Test.stopTest();
        
              
     }

}

Am I at least on the right path?
I am creating a VF page where students will choose their school from a dropdown list and then based on the selection, proceed to a registration page specific to that school. I am creating the list, grabbing the Name and ID, in a custom controller. I've the the dropdown working, but I'm stuck on how to get the ID once the school is selected and appending it to a URL so that the students are directed to the right page. Any thoughts?

My code for reference:
VF page:
<apex:page showHeader="false" sideBar="false" standardStylesheets="false" docType="html-5.0" applyBodyTag="false" applyHtmlTag="false" controller="SDPController">
    <script>
    
	</script>
<apex:composition template="{!$Site.Template}">
    <apex:define name="title">{!$Label.LBL_Page_Title}</apex:define>
    <apex:define name="body">
    <div class="container">
        <div align="center" style="font-size:20px;">
        <p>Welcome to the Digital On-Ramps ePortfolio! Please select you school and click "Next."</p>
        <apex:form >
        	<apex:selectList multiselect="false" size="1"  required="false" style="font-size:20px;">
            	<apex:selectOptions value="{!PAIList}" />
            </apex:selectList>
            <div class="modal-footer">
            <apex:commandButton id="register" value="Next" />
        </div>
        </apex:form>
        </div>
        
    </div>
    </apex:define>
</apex:composition>   
</apex:page>

And controller:
public without sharing class SDPController {
    public List<Account> PAISchools = new List<Account>();
    public SDPController(){
        
    }

    public List<SelectOption> PAIList{
        get{
            PAISchools = [Select Account.Name, Account.Id From Account Where Account.ParentId = '0011700000BZkKR'];
            
            PAIList = new List<SelectOption>();
            
            for(Account temp : PAISchools){
                PAIList.add(new SelectOption(temp.id, temp.Name));
            }
            return PAIList;
        }
        set;    
    }
  
        
}

 
Hello,

I have created a flow whereby visitors to our community center can sign in and register for the programs they are attending. We are going to start collecting demographics data soon, and as a result, I am encountering the error in the heading: UPDATE --- UPDATE FAILED --- ERRORS : (CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY) entity type cannot be updated: Contact, 

The flow is displayed through a site and the visitor views the site as a guest user. Checking the guest user profile, I found that I cannot allow the guest user to edit standard sObject records and I believe this is what is causing the issue. Any thoughts on a work around?
Hello,

I created a flow to check people in at a community center. It has been functioning fine until yesterday when I started getting an error: "INSERT --- INSERT FAILED --- ERRORS : (CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY) entity type cannot be inserted: Campaign Member,"

The flow is displayed through a Visualforce page in a site. The error is only thrown when the flow is run through the page or site. No edits have been made to the page or site in the past week, so I'm not sure what caused this error. It's no longer happening, but I'd like to get to the bottom of this.

Any thoughts?