• Behzad
  • NEWBIE
  • 110 Points
  • Member since 2009

  • Chatter
    Feed
  • 4
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 12
    Questions
  • 8
    Replies

Hey guys,

 

I have a JavaScript List Button that I'm using on a Related List.

 

Users are to select a number of records from the serviceVendorPartnership Related List, and click on Disable button that automatically changes the branchType__c picklist field to "None" for selected records. 

 

I know that I have to update a list of records, and I'm using an update connection method to update all records in the list, as highlighted in my code below:

 

{!REQUIRESCRIPT("/soap/ajax/16.0/connection.js")} 
records = {!GETRECORDIDS($ObjectType.serviceVendorPartnership__c)};

var newRecords = [records];

//Making Sure user has selected at least one row
if(records.length<1) {
alert("Please choose at least one Service Vendor Location to disable.");
} else {

//Confirming user's action
var r = confirm("Click ''OK'' to disable selected Service Vendor Locations.");
if (r == true) {
try {

records.branchType__c = 'None';
result = sforce.connection.update([newRecords]);
window.location.reload();

if (result[0].getBoolean("success")) {
alert("Service Vendor Location with id " + result[0].id + " updated");
} else {
alert("failed to update Service Vendor Location" + result[0]);
}
}
catch (e) {
alert(e);
}
}

 

 

My button is throwing the following error message:

failed to update Service Vendor Location{errors:{message:'sObject type 'sObject' is not supported. If you are attempting to use a custom object, be sure to append the '__c' after the entity name. Please reference your WSDL or the describe call for the appropriate names.', statusCode:'INVALID_TYPE', }, id:null, success:'false', }

 

Does anyone know why the id list is returning null?

 

I greatly appreciate your feedbacks.

 

Thank you,

 

Behzad

Hey all,

 

I got a wrapper that I use for multiselection. I previously used its code in a component controller, but now I want to use it in a constructor extentsion.

 

Here is the code that I got:

 

public with sharing class partnershipDeactivatorController {

public program__c prog {get;set;}
public distributionPartnership__c dp {get;set;}
public Terminal__c trm {get;set;}
public Location__c [] locs = new Location__c[0];
public Terminal__c [] trms = new Terminal__c[0];


public distributionPartnership__c [] dps = new distributionPartnership__c[0];
public List<String> recordIds {get;set;}


public string progId {get;set;}
public string retUrl {get;set;}
public string idsToSplit {get;set;}
public string schedule {get;set;}
public string cmd {get;set;}

//Variables for multiselector on Deactivation Partnerhisp Page
public boolean topCheckbox {get; set;}
List<rcrdWrapper> rcrdList {get;set;}

//Constructor
public ApexPages.StandardController controller;
public partnershipDeactivatorController(ApexPages.StandardController controller) {
this.controller = controller;
//make it easy to map page params
PageReference pageRef = ApexPages.CurrentPage();
Map<String, String> page = pageRef.getParameters();

dp = (distributionPartnership__c) controller.getrecord();
Terminal__c trm = new Terminal__c();

progId = page.get('progId');
retUrl = page.get('retUrl');

if (progId != null) {
prog = getProg();
dp.Program__c = prog.id;
}

string s = page.get('records');
this.idsToSplit = s;
this.recordIds = this.idsToSplit.split(',',0);

}

//Get the locations from the list of ids specified
public Terminal__c[] getTrms(){
Trms = [
SELECT
id,
distributionPartnership__c,
Type__c,
Location__c
FROM Terminal__c
WHERE distributionPartnership__c IN :recordIds
];
return Trms;
}

//Get the program
public program__c getProg(){
prog = [select
id,
group__c
from program__c
where id = :progId
limit 1
];
return prog;
}
public void cmdBtn(){
}

//{!rcrds} is the pageBlockTable value to render
public List<rcrdWrapper> rcrds
{
get
{
if (rcrdList == null)
{
rcrdList = new List<rcrdWrapper>();
Terminal__c[] trms = [
SELECT
id,
distributionPartnership__c,
Type__c,
Location__c
FROM Terminal__c
WHERE distributionPartnership__c IN :recordIds
];

for(Terminal__c trm : trms)
rcrdList.add(new rcrdWrapper(trm));

}
return rcrdList;
}
}

private List<rcrdWrapper> selectedRows
{
get
{
List<rcrdWrapper> selectedRows = new List<rcrdWrapper>();

for(rcrdWrapper row : rcrds)
if(row.selected == true)
selectedRows.add(row);

return selectedRows;
}
}

public class rcrdWrapper
{
public distributionPartnership__c rcrd{get; set;}
public Boolean selected {get; set;}

public rcrdWrapper(distributionPartnership__c dp)
{
rcrd = dp;
selected = false;
}
}
}

 

 

The highlighted codes is givving me the following error:

 

Save error: Constructor not defined:
 [partnershipDeactivatorController.rcrdWrapper].<Constructor>(SOBJECT:Terminal__c)

 

I understand this error code, but I don't know how to define the recordWrapper in my constructor.

 

Your help is greatly appreciated.

 

Thanks,

 

Behzad

Hey guys,

 

I'm trying to add a number of days calculation in my Visualforce page, and this calculation is basically counting the number of days left to the end of a process.

 

I'm working with a date/time field, axns.Finish_date_time__c, so I use the ROUND() function to calculate the number of days only.

 

Here is the formula that I use to calculate the number of days left for my process:

 

ROUND(axns.Finish_date_time__c-DATEVALUE(NOW()),0)

 

This formula works well, but for some reason when it is equal to 10 days it shows the number in the following manner: 1E+1

 

 

Is there a way to display this number as 10?

 

 

Thank you,

 

Behzad

Hey guys,

 

I've created a Visualforce page for a number of users.

Some of my Org users use IE and some use Firefox.

 

For some reason, my Visualforce page is displayed differently in each web browser.

 

This is a sample of my Visualforce code:

<apex:pageBlock title="IMAC Detail" id="detailPageBlock"> <apex:panelGrid columns="4" rules="rows" styleClass="panelGridClass" title="IMAC detail" width="100%" columnClasses="panelGridLabel, panelGridValue"> <apex:outputText value="IMAC" /> <apex:panelGroup > <apex:outputField value="{!IMAC__c.Name}" rendered=" {!IMAC__c.ID != inlineEditId}"/> <apex:inputField value="{!IMAC__c.Name}" rendered=" {!IMAC__c.Id == inlineEditId}"/> </apex:panelGroup> <apex:outputText value="Owner" /> .... </apex:panelGrid> </apex:pageBlock>

 Also, the following figure highlights the differences between displayed pages in IE and in FireFox:

 IE vs. Firefox


Does anyone know what I need to do so my Visualforce page would render consistenlty accross these web browsers?

 

Thank you,

 

Behzad

 

Hey guys,

 

I'm trying to use HelpTitle and HelpUrl in my pageBlocks to point to specific Headers on a WikiPedia page.

I specify particular Urls that should point to a header, but when I click on the help links it just takes me to the page instead of the header.

 

For example, the following help url should take me to the All Details header, but it just takes me to the Detail page instead

 

<apex:pageBlock title="Detail"
helpTitle="Detail Help"
helpUrl="https://www.THEWIKI.com/index.php?title=Detail#All_Details"
id="detailPageBlock">
</apex:pageBlock>

 It results in the following URL:

 

https://www.THEWIKI.com/index.php?title=Detail%23All_Details&showSplash=true

 

The above throws me to the Detail page, and not the All Detail header on that page.

 

How should I change it so it properly points to the All Detail header?

 

 

 

 

Your help is greatly appreciated.

 

Thank you and happy new year,

 

Behzad

Hey guys,

 

In the case object, I store a number of lookup fields that they all have parent-child relationships. I'm trying to build a Custom Link which gets the parent lookup fields with OnClick JavaScript. I tend to use the Execute JavaScript behavior for my Custom Link. In my JavaScript code, I use a query function to retreive the parent object base on my criteria. The code is as follows:

{!REQUIRESCRIPT("/soap/ajax/16.0/connection.js")} var newRecords = []; var C = new sforce.SObject("Case"); //Parent-Child Object Relationship is as follow: Terminal>>Part var PartParentTerminal = sforce.connection.query("SELECT Terminal__c FROM Part__c WHERE Part__c.Id= '{!Case.PartId__c}' "); //Updating parents via the PART association C.id ="{!Case.Id}"; C.Terminal__c = PartParentTerminal; newRecords.push(C); result = sforce.connection.update(newRecords); window.location.reload();

 This custom link results in the following error code:

 

{faultcode:'soapenv:Client', faultstring:'Unexpected element {urn:partner.soap.sforce.com}done during simple type deserialization', }

 I don't understand the error code and the reasons behind it.

 

I appreciate your thoughts about this issue.

 

Thank you,

 

Behzad

 

 

 

Hey all,

 

I wanted to update a field in a custom object using Visualforce.

 

The custom object that I am working on is called "Parts". And, the field that I'm looking to update in this custom object is called "Part Name."

 

The field "Part Name" is consisted of two fields "Part Model Name" and "Location Address." The "Part Model Name" is a field in the Parts object which stores the part model. The "Location Address" is a field in the Location obejct which stores location address.The Parts custom object looks up to a Location custom object- has a child relationship with the Location object.

 

Custom Object Relationship:

Location (Has a field called Location Address) --> Part (Has a field called Part Model Name)

 

Part Name Field in the Parts Object to be updated:

Part Name = Part Model Name @ Location Address

 

I currently use an extra field in the part object to grab the location address information, and I currently update the Part Name field via a Field update. However, I would like to get rid of that extra field and perform the field update through a Visualforce.

 

I don't have sufficient Visualforce knowledge to do this. Any help or comment is greatly appreciated.

 

Thanks,