• AditiSFDC
  • NEWBIE
  • 130 Points
  • Member since 2012

  • Chatter
    Feed
  • 4
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 27
    Replies

Hi Guys,

 

Below is the code for attaching a file in a record. I want to create a validation rule so that user can only upload jpeg files. Is there a way to do this? please help.

 

Thanks,

Del

 

 

 

public with sharing class AttachmentUploadController {
 
  public Attachment attachment {
  get {
      if (attachment == null)
        attachment = new Attachment();
      return attachment;
    }
  set;
  }
 
  public PageReference upload() {
 
    attachment.OwnerId = UserInfo.getUserId();
    attachment.ParentId = '001W0000005v6Ih'; // the record the file is attached to
    attachment.IsPrivate = true;
 
    try {
      insert attachment;
    } catch (DMLException e) {
      ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,'Error uploading attachment'));
      return null;
    } finally {
      attachment = new Attachment(); 
    }
 
    ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO,'Attachment uploaded successfully'));
    return null;
  }
 
}

My apex code is given i want to display the value of include2 on button click it is not working.
with regards
Shine
  ------------Apex code---------
public string timestampValue{get;set;}
public new2(){
timeStampValue = 'm';
}
public void sendTimestamp()
{
    timestampValue='timestampValue--' + timeStampValue;
//system.debug('timestampValue' + timeStampValue);
}

}
------------Apex code---------
-------------javascript code---------
var include2='';
function showIndustriesId(theId,obj)
{
    if(obj.checked)
    {
        include2=include2.concat((','+theId));
        alert(include2);
    }
    else
    {
        include2=include2.replace((','+theId),'');
        alert(include2);
    }
}
function sendTimeStamp()
{
    var timeStamp=include2;
          sendTimeStamp(timeStamp);
}

-------------javascript code---------
-------------visual force---------
<apex:form >
  <apex:commandButton value="pass" onclick="sendTimeStamp()"/>
          <apex:actionFunction name="sendTimeStamp" action="{!sendTimeStamp}" >
    <apex:param name="x" value="" assignTo="{!timeStampValue}" />
</apex:actionFunction>
    </apex:form>
-------------visual force---------

Has anyone tried creating Sharing rule using Metadata API version 33.0?

I want to create an owner based sharing rule using metadata and below is the code snippet method which is calling MetadataService33 class created by Metadata WDSL.
public static void createSharingRule(String objectName, String ruleName, String ruleLabel, String groupName) {
		MetadataService33.MetadataPort stub = createService33();
		
		MetadataService33.SharingRules sharingRule = (MetadataService33.SharingRules) stub.readMetadata('SharingRules', new String[] { objectName }).getRecords()[0];
		
		//MetadataService33.SharingRules sharingRule = new MetadataService33.SharingRules();
		//sharingRule.fullName = objectName  ;
		
		MetadataService33.SharingCriteriaRule criteriaRuleOfObject = new MetadataService33.SharingCriteriaRule();
		MetadataService33.FilterItem criteriaItemOfRule = new MetadataService33.FilterItem();
		criteriaItemOfRule.operation = 'equals' ;
		criteriaRuleOfObject.criteriaItems = new List<MetadataService33.FilterItem> {criteriaItemOfRule} ;
		criteriaRuleOfObject.booleanFilter = 'False' ;
		MetadataService33.SharedTo sharedToGrpC = new  MetadataService33.SharedTo() ;
		criteriaRuleOfObject.sharedTo = sharedToGrpC ;
		
		
		MetadataService33.SharingTerritoryRule territoryRuleOfObject = new MetadataService33.SharingTerritoryRule();
		MetadataService33.SharedTo sharedFrmGrpT = new  MetadataService33.SharedTo() ;
		MetadataService33.SharedTo sharedToGrpT = new  MetadataService33.SharedTo() ;
		territoryRuleOfObject.sharedFrom = sharedFrmGrpT ;
		territoryRuleOfObject.sharedTo = sharedToGrpT ;
		
		
		MetadataService33.SharingOwnerRule ownerRuleOfObject = new MetadataService33.SharingOwnerRule();
		ownerRuleOfObject.fullName = ruleName ;
		ownerRuleOfObject.accessLevel = 'Edit' ;
		ownerRuleOfObject.label = ruleLabel ;
		
		MetadataService33.SharedTo sharedFrmGrp = new  MetadataService33.SharedTo() ; 
		sharedFrmGrp.group_x = new String[] {groupName} ; 
		
		MetadataService33.SharedTo sharedToGrp = new  MetadataService33.SharedTo() ;
		sharedToGrp.group_x = new String[] {groupName} ;
		
		ownerRuleOfObject.sharedFrom = sharedFrmGrp ;
		ownerRuleOfObject.sharedTo = sharedToGrp ;
		
		if(sharingRule.sharingOwnerRules != null)
			sharingRule.sharingOwnerRules.add(ownerRuleOfObject) ;
		else
			sharingRule.sharingOwnerRules =  new List<MetadataService33.SharingOwnerRule> {ownerRuleOfObject} ;
			
		if(sharingRule.sharingCriteriaRules == null)
			sharingRule.sharingCriteriaRules =  new List<MetadataService33.SharingCriteriaRule> {criteriaRuleOfObject} ;
		
		if(sharingRule.sharingTerritoryRules == null)
			sharingRule.sharingTerritoryRules = new List<MetadataService33.SharingTerritoryRule> {territoryRuleOfObject} ;
		
		MetadataService33.SaveResult[] resp = stub.updateMetadata(new MetadataService33.Metadata[] { sharingRule });
		// MetadataService33.SaveResult[] resp = stub.createMetadata(new MetadataService33.Metadata[] { sharingRule });
		// MetadataService33.UpsertResult[] resp = stub.upsertMetadata(new MetadataService33.Metadata[] { sharingRule });
		system.debug('====> ' + resp);
		handleSaveResults33(resp[0]);
	}

When I call above method for a standard object like Contact, I get sucess message from salesforce though no rules is created in actual and when I call it for a custom object, I get unknow exception from saleforce. ReadMetadata call works perfectly fine and give proper result but updating sharing rule metadata gives me error.


Here is the code snippet how I call the method:
/* @1st parameter: Object API name
    @2nd parameter: Sharing rule name
    @3rd parameter: Sharing rule Label
    @4th parameter: Existing public group name
*/
MetadataWebserviceCall.createSharingRule('Contact', 'Test_Owner_Sharing_Rule2', 'Test Owner Sharing Rule2', 'AD_Sharing_Group');

Thanks in advance.

 
Is it possible to create owner or criteria based Sharing rules for both custom and standard object via Metadata API?
When I look at metadata.xml (version 32), CustomBasedSharingRules or any other Standard object sharing rules indirectly extends Metadata class but when I generate WSDL2Apex class, they don't extend Metadata class.
Adding a Long Text Area field in a Select query then it returns weird number of records then actual records available or returned when using select query without Long Text Area field.

However, adding more than one Long Text Area field in select query, number of records decreased even more as compared to those which returned with single Long Text Area field.

Let Say :

We have two Object A & B. B is A child and have two long text area fields lat sat Long_Desc_1 and Long_Desc_2.

Number of A's record exists : more than 5000
Number of B's record exists : more than 3000

where around 2900 B's record belongs to a single Parent record.

Query results :
  1. Select Long_Desc_1 from B    (Returns exact 2000 records)
  2. Select Long_Desc_1, Long_Desc_2 from B    (Returns exact 1000 records)
  3. Select Id, (Select Long_Desc_1 from B) from A     (Returns around 3700 records)
  4. Select Id, (Select Long_Desc_1, Long_Desc_2 from B) from A  (Returns around 3200 records)
Not able to find any documented Limitation on Long Text Area field and not able to find any exact pattern for returned number of records.

Thanks
Has anyone tried creating Sharing rule using Metadata API version 33.0?

I want to create an owner based sharing rule using metadata and below is the code snippet method which is calling MetadataService33 class created by Metadata WDSL.
public static void createSharingRule(String objectName, String ruleName, String ruleLabel, String groupName) {
		MetadataService33.MetadataPort stub = createService33();
		
		MetadataService33.SharingRules sharingRule = (MetadataService33.SharingRules) stub.readMetadata('SharingRules', new String[] { objectName }).getRecords()[0];
		
		//MetadataService33.SharingRules sharingRule = new MetadataService33.SharingRules();
		//sharingRule.fullName = objectName  ;
		
		MetadataService33.SharingCriteriaRule criteriaRuleOfObject = new MetadataService33.SharingCriteriaRule();
		MetadataService33.FilterItem criteriaItemOfRule = new MetadataService33.FilterItem();
		criteriaItemOfRule.operation = 'equals' ;
		criteriaRuleOfObject.criteriaItems = new List<MetadataService33.FilterItem> {criteriaItemOfRule} ;
		criteriaRuleOfObject.booleanFilter = 'False' ;
		MetadataService33.SharedTo sharedToGrpC = new  MetadataService33.SharedTo() ;
		criteriaRuleOfObject.sharedTo = sharedToGrpC ;
		
		
		MetadataService33.SharingTerritoryRule territoryRuleOfObject = new MetadataService33.SharingTerritoryRule();
		MetadataService33.SharedTo sharedFrmGrpT = new  MetadataService33.SharedTo() ;
		MetadataService33.SharedTo sharedToGrpT = new  MetadataService33.SharedTo() ;
		territoryRuleOfObject.sharedFrom = sharedFrmGrpT ;
		territoryRuleOfObject.sharedTo = sharedToGrpT ;
		
		
		MetadataService33.SharingOwnerRule ownerRuleOfObject = new MetadataService33.SharingOwnerRule();
		ownerRuleOfObject.fullName = ruleName ;
		ownerRuleOfObject.accessLevel = 'Edit' ;
		ownerRuleOfObject.label = ruleLabel ;
		
		MetadataService33.SharedTo sharedFrmGrp = new  MetadataService33.SharedTo() ; 
		sharedFrmGrp.group_x = new String[] {groupName} ; 
		
		MetadataService33.SharedTo sharedToGrp = new  MetadataService33.SharedTo() ;
		sharedToGrp.group_x = new String[] {groupName} ;
		
		ownerRuleOfObject.sharedFrom = sharedFrmGrp ;
		ownerRuleOfObject.sharedTo = sharedToGrp ;
		
		if(sharingRule.sharingOwnerRules != null)
			sharingRule.sharingOwnerRules.add(ownerRuleOfObject) ;
		else
			sharingRule.sharingOwnerRules =  new List<MetadataService33.SharingOwnerRule> {ownerRuleOfObject} ;
			
		if(sharingRule.sharingCriteriaRules == null)
			sharingRule.sharingCriteriaRules =  new List<MetadataService33.SharingCriteriaRule> {criteriaRuleOfObject} ;
		
		if(sharingRule.sharingTerritoryRules == null)
			sharingRule.sharingTerritoryRules = new List<MetadataService33.SharingTerritoryRule> {territoryRuleOfObject} ;
		
		MetadataService33.SaveResult[] resp = stub.updateMetadata(new MetadataService33.Metadata[] { sharingRule });
		// MetadataService33.SaveResult[] resp = stub.createMetadata(new MetadataService33.Metadata[] { sharingRule });
		// MetadataService33.UpsertResult[] resp = stub.upsertMetadata(new MetadataService33.Metadata[] { sharingRule });
		system.debug('====> ' + resp);
		handleSaveResults33(resp[0]);
	}

When I call above method for a standard object like Contact, I get sucess message from salesforce though no rules is created in actual and when I call it for a custom object, I get unknow exception from saleforce. ReadMetadata call works perfectly fine and give proper result but updating sharing rule metadata gives me error.


Here is the code snippet how I call the method:
/* @1st parameter: Object API name
    @2nd parameter: Sharing rule name
    @3rd parameter: Sharing rule Label
    @4th parameter: Existing public group name
*/
MetadataWebserviceCall.createSharingRule('Contact', 'Test_Owner_Sharing_Rule2', 'Test Owner Sharing Rule2', 'AD_Sharing_Group');

Thanks in advance.

 

Vertical tabs is not working ... problem in Jquery

 

<apex:page>
<style>
body {
    background: #f0f0f0;
    margin: 0;
    padding: 0;
    font: 10px normal Verdana, Arial, Helvetica, sans-serif;
    color: #444;
    }
.container {width: 500px; margin: 10px auto;}
ul.tabs {
    margin: 0;
    padding: 0;
    float: left;
    list-style: none;
    height: 32px;
    border-bottom: 1px solid #999;
    border-left: 1px solid #999;
    width: 20%;
    }
ul.tabs li {
    float: top;
    margin: 0;
    padding: 0;
    height: 31px;
    line-height: 31px;
    border: 1px solid #999;
    border-left: none;
    margin-bottom: 0px;
    background: #e0e0e0;
    overflow: hidden;
    position: relative;
    }
ul.tabs li a {
    text-decoration: none;
    color: #000;
    display: block;
    font-size: 1.2em;
    padding: 0 20px;
    border: 1px solid #fff;
    outline: none;
}
ul.tabs li a:hover {
    background: #ccc;
}   
html ul.tabs li.active, html ul.tabs li.active a:hover  {
    background: #fff;
    border-bottom: 1px solid #fff;
}
.tab_container {
    border: 1px solid #999;
    width: 200%;
    background: #fff;
    -moz-border-radius-bottomright: 5px;
    -khtml-border-radius-bottomright: 5px;
    -webkit-border-bottom-right-radius: 5px;
    -moz-border-radius-bottomleft: 5px;
    -khtml-border-radius-bottomleft: 5px;
    -webkit-border-bottom-left-radius: 5px;
    }
.tab_content {
    padding: 120px;
    font-size: 1.2em;
    }
.tab_content h2 {
    font-weight: normal;
    padding-bottom: 10px;
    border-bottom: 1px dashed #ddd;
    font-size: 1.8em;
}
</style>
<script>
$(document).ready(function() {
    //Default Action
    $(".tab_content").hide(); //Hide all content
    $("ul.tabs li:first").addClass("active").show(); //Activate first tab
    $(".tab_content:first").show(); //Show first tab content

    //On Click Event
    $("ul.tabs li").click(function() {
    $("ul.tabs li").removeClass("active"); //Remove any "active" class
    $(this).addClass("active"); //Add "active" class to selected tab
    $(".tab_content").hide(); //Hide all tab content
    var activeTab = $(this).find("a").attr("href"); //Find the rel attribute value to identify the active tab + content
    $(activeTab).fadeIn(); //Fade in the active content
    return false;
    });

});
</script>

<div class="container">
<ul class="tabs">
    <li><a href="#tab1">Gallery</a></li>
    <li><a href="#tab2">Submit</a></li>
    <li><a href="#tab2">The Third</a></li>
</ul>
<div class="tab_container">
    <div id="tab1" class="tab_content">
        <h2>Gallery</h2>
        <p>Text 1 </p>
    </div>
    <div id="tab2" class="tab_content">
        <h2>Submit</h2>
        <p>Text 2 </p>
    </div>
    <div id="tab3" class="tab_content">
        <h2>The last one</h2>
        <p>Text 3 </p>
    </div>
</div>
</div>
</apex:page>

 

please correct this bug...

  • October 01, 2013
  • Like
  • 0
function doItWrapper() {
  // alert("in doItWrapper()");
  doItFunc();
}  
...
<apex:actionFunction name="doItFunc" action="{!doItInner}" rerender="resultPanel"/>

...
Change Me: <input type="text" id="fname" onchange="doItWrapper()"/>
...
<apex:commandButton value="Do It Wrapper" onClick="doItWrapper();" />

 

Relavent portion of code above.

 

I find that when the commandButton is pressed, the doItWrapper() function is execute which in turns executes the doItFunc actionFunction.  The actionFunction does call the server.  But, the rerender doesn't happen,  resultPanel is an outputPanel and its contents do not change.

 

When I change the value in the field labelled "Change me", it works fine.  doItWrapper() is called; the actionFunction is called which calls the server; and then the panel is rerendered just fine.

 

Anyone know why the rerender doesn't work when the script is invoked from commandButton but is when invoked from an input field?

 

hi,

 I created 2 custom objects with lookuprelation,

i placed a picklist on vfpage and i placed related field values in that picklist,

i want to display table when i select a value from picklist , plese help 

  • September 25, 2013
  • Like
  • 0

How can i show the show or hide for the individual sections.. not for all.

 

page:

 

<apex:page controller="questionsClass">
<apex:form >
<apex:actionfunction name="showAnswer" action="{!showAnswer}" rerender="out1"/>
<apex:actionfunction name="hideAnswer" action="{!hideAnswer}" rerender="out1"/>

<!--
<apex:commandLink value="Expand" action="{!showAnswer}" reRender="out1"/> | &nbsp;
<apex:commandLink value="Collapse" action="{!hideAnswer}" rerender="out1"/>
-->

<apex:outputpanel id="out1">
<table>
<tr height="20px;">
</tr>
<apex:repeat value="{!lstQC}" var="QC">
<tr>
<td>
<apex:image value="{!$Resource.plus}" onclick="showAnswer();" rendered="{!plusimg}"/>
<apex:image value="{!$Resource.minus}" onclick="hideAnswer();" rendered="{!minusimg}"/>
</td>
<td>
<apex:outputtext value="{!QC.q}" style="font-size:15px;font-weight:bold;color:red;"/>
</td>
</tr>
<tr >
<td>
</td>
<td >
<apex:outputtext value="{!QC.a}" style="margin-left:50px;color:green;" rendered="{!expandedval}"/>
</td>
</tr>
</apex:repeat>
</table>
</apex:outputpanel>
</apex:form>
</apex:page>

 

 

class:

 

public with sharing class questionsClass {

public void hideAnswer() {
expandedval = false;
minusimg = false;
plusimg = true;

}

public void showAnswer() {
expandedval = true;
minusimg = true;
plusimg = false;
}


public boolean minusimg { get; set; }
public boolean plusimg { get; set; }
public boolean expandedval { get; set; }
public List<Q_A__c> lstqa{get;set;}
public List<QuesClass> lstQC{get;set;}
public questionsClass(){
expandedval = false;
plusimg = true;
minusimg = false;
lstqa = new List<Q_A__c>();
lstqa = [select id,name,answer__c from Q_A__c];
lstQC = new List<QuesClass>();
for(Integer i=0;i<lstqa.size();i++){
QuesClass objQC = new QuesClass();
objQC.q = lstqa[i].Name;
objQC.a = lstqa[i].answer__c;
lstQC.add(objQC);
}
}

public class QuesClass{
public String q{get;set;}
public String a{get;set;}
}
}

 

 

Once i clicked on + for any record it was expanding all sections... But not the specific one.

 

I need to show only the specific section that i clicked.

 

Can you help me.

I have an After Update trigger that updates the fields on a parent object, and that object has several validation rules that have the potential to fire if they're met when the After Update trigger runs.

 

Instead of the normal DML exception though where it reads like gibberish and sends me an error email and leaves the user scratching their head, how would I display a custom error message, prevent the DML insert, and have the system NOT clog my email with exception messages?

 

The section of my code that triggers the DML is as follows:

 

    try{
    update processedOpportunitiesList;
    } catch(DMLException e){
        if(e.getMessage().contains('FIELD_CUSTOM_VALIDATION_EXCEPTION, Please enter Shipping Address, City, State and Zip')){
            e.addError('You can\'t select this stage until you first enter the Shipping Address info on the opportunity.');
        }
    }

 In the above code, I'm trying to say that, if running the DML update with the list "processedOpportunitiesList" results in a DML exception that contains the sentence "FIELD_CUSTOM_VALIDATION_EXCEPTION, Please enter Shipping Address, City, State and Zip", then I want to instead display "You can't select this stage until you first enter the Shipping Address info on the opportunity." to the user, prevent salesforce from inserting the record, and have it not email me about the exception.

 

However, I seem to not be grasping how this particular class is structured or how I'm supposed to write it.  I keep getting "Method does not exist or incorrect signature" errors as I fiddle around with the code and I'm realizing that I'm not "getting" this and I should probably ask on here for help.  Can someone please tell me how I would need to write or structure this trigger properly?

 

Thanks.

Hello!

 

I have 2 objects, a ship to and an account.  If a user has access to the ship tochild record they should also have access to the account.  Access is granted by the Saels Rep Code on the ship to record.  This will need to match the Rep ID on the user record.  So far this is what I have.  I continue to get User.Rep__ID__c at line 7 unexpected token.  Any thoughts or code correction are greatly appreciated.  Thanks!

trigger shareSPA on InForceEW__shipto__c (after insert, after update) {

  //SPA_Share is the share table that was created when the OWD was set to "Private"
  List <Ship_To_Sharing> shiptoShares = new List <Ship_To_Sharing>();
  
  for(User us:[select Id, Rep_ID__c from User]);
  for (InForceEW__shipto__c st : [select Id,InForceEW__Account__c,Sales_Rep_Code__c From InForceEW__shipto__c Where Sales_Rep_Code__c=User.Rep_ID__c];  {


    if (trigger.isInsert) {
      Ship_To_Sharing shiptoShares = new Ship_To_Sharing();
      shiptoShares.ParentId = st.InForceEW__Account__c;
      shiptoShares.UserOrGroupId = st.Sales_Rep_Code__c;
      shiptoShares.AccessLevel = 'edit';
      shiptoShares.RowCause = Schema.Ship_To_Sharing.RowCause.ShipToSharing__c;
        
      shiptoShares.add(shiptoShare);
    }
    if (trigger.isUpdate) {
      InForceEW__shipto__c oldShipTo = Trigger.oldMap.get(shp.Id);
      if(shp.Sales_Rep_Code__c != oldDiscount.Sales_Rep_Code__c) {
      Ship_To_Sharing shiptoShares = new Ship_To_Sharing();
      shiptoShares.ParentId = st.InForceEW__Account__c;
      shiptoShares.UserOrGroupId = st.Sales_Rep_Code__c;
      shiptoShares.AccessLevel = 'edit';
      shiptoShares.RowCause = Schema.Ship_To_Sharing.RowCause.ShipToSharing__c;
        
        shiptoShares.add(shiptoShare);      
      }
    }
  }

  Database.SaveResult[] shiptoShareInsertResult = Database.insert(shiptoShares, false);

}
}

 

 

Seems like someone would have written a component that could be reused for getting a date as an input field that has a date picker without having to always have an object date to use.

 

For instance, I want to have an input for a start date and and end date for a report or listing that has a date picker. Those dates could then be fed into a filter.. I am suggesting a component as it could be reused.

I am working on this project where I have downloaded the managed app into my salesforce. I am hosting visual force page on our internal website where people can go and signup for volunteer work.

 

My problem is that I want to display a link / URL on the visual force page, when the user will click this link it should open a PDF file. But unfortunately this is managed app and I can't add the link by editing the code in the Visual force page. I was hoping is someone can direct me how to do this. Its very critical.

  • September 20, 2013
  • Like
  • 0

Hi,

 

I have just noticed a behaviour that seems strange to me.

 

 

Consider the following scenario:

- MasterCustomObject__c

- DetailCustomObjectA__c (related with MasterCustomObject__c)

- DetailCustomObjectB__c (related with MasterCustomObject__c)

 

 

 

Now consider the following actions that are performed consecutively:

 

1. If I delete DetailCustomObjectA__c, it is naturally thrown into recycle bin and cannot be queried via SOQL (everything is clear at this point)

 

2. If I delete MasterCustomObject__c afterwards, it is thrown into recycle bin.

  2.1 DetailCustomObjectB__c is not visible in recycle bin

  2.2 DetailCustomObjectA__c  -  which has been deleted in (1)  -  is no longer visible in recycle bin

 

3. After undeleting MasterCustomObject__c from recycle bin, the situation is as follows:

  3.1 MasterCustomObject__c is available again

  3.2 DetailCustomObjectB__c is accesible again

  3.3 but DetailCustomObjectA__c remains lost, i.e. it cannot be queried via SOQL nor is it visible in recycle bin.

 

 

 

I would have expected, that after deleting Master-Detail objects - no matter of chronological order of deletion and undeletion - all objects had to be back again.

Is there any explanation for the observed behaviour or even an option to fix this problem?

 

Thanks in advance for any assistance!

Hi Guys,

 

Below is the code for attaching a file in a record. I want to create a validation rule so that user can only upload jpeg files. Is there a way to do this? please help.

 

Thanks,

Del

 

 

 

public with sharing class AttachmentUploadController {
 
  public Attachment attachment {
  get {
      if (attachment == null)
        attachment = new Attachment();
      return attachment;
    }
  set;
  }
 
  public PageReference upload() {
 
    attachment.OwnerId = UserInfo.getUserId();
    attachment.ParentId = '001W0000005v6Ih'; // the record the file is attached to
    attachment.IsPrivate = true;
 
    try {
      insert attachment;
    } catch (DMLException e) {
      ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,'Error uploading attachment'));
      return null;
    } finally {
      attachment = new Attachment(); 
    }
 
    ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO,'Attachment uploaded successfully'));
    return null;
  }
 
}

i have  a problem when i rerender a part of a page then i am able to get javascript values  that are there in that page.

with that echo function(name) i get the three values

 

When i remove the rerender ,in thecase when i want to redirect to another page after getting the thrre  values in the page from javascript ,iam not getting the values.in that page the function returns the three values correctly.IS there any substitute for rerender in that scenario.

Please do help me

Regards

Punnoose

*******************************CODE**********************************

<apex:actionFunction name="echo" action="{!echoVal}" reRender="resultPanel" status="myStatus">
            <apex:param name="Param1"  value="" />
            <apex:param name="Param2"  value="" />
            <apex:param name="Param3"  value="" />
        </apex:actionFunction>

*******************************CODE**********************************

Hi team,

I am totally new in SFDC Development and I have a big issue .
The previous Developer in my company has gone and I don't manage to resolve the redirection myself.
I would be fully grateful if someone could correct this code.

The problem of my users is the following :

" When I create a New task ,I fill in the datas in the form and I click on the save button on New Event page , I would like to be redirected to the Current view task page (URL + task id)
instead of to be redirected to the Account page ."

I don't know anything about coding in Apex so I really need your help...

I have currently a Visualoforce page nammed : TaskRedirect with this code :

<apex:page standardController="Task" extensions="TaskRedirectController" action="{!redirect}">
</apex:page>

            
It is display for a New Task, and below you will find the code of the Apex Class that is called, could you tell me what I should write to be redirect to the URL + Task_id after save??


public with sharing class TaskRedirectController {
    public final Task task;
    public User userData;
    
    public TaskRedirectController(ApexPages.StandardController redirectController)
    { 
        //get the current record
        this.task=(Task)redirectController.getRecord();
        userData = [SELECT Business_Group__c, Business_Unit__c, User_Division__c, User_Subdivision__c FROM User WHERE Id = :UserInfo.getUserId()]; 
    }
    public PageReference redirect(){
        String what_id = ApexPages.currentPage().getParameters().get('what_id');
        String who_id = ApexPages.currentPage().getParameters().get('who_id');
        String Record_Type = ApexPages.currentPage().getParameters().get('RecordType');
        String task_Id = ApexPages.currentPage().getParameters().get('Id');
        String accid = ApexPages.currentPage().getParameters().get('AccountId');
   
       if(accid == null)
           accid ='';
       if(what_id == null)
           what_id = '';
       if (who_id == null)
           who_id = '';
       if (task_id == null)
           task_id = '';
                 
 String str='/00T/e?retURL=%2F001%2Fo&nooverride=1&00N20000001kXCH='+replaceStr(userData.Business_Group__c)+'&00N20000001kXCL='+replaceStr(userData.Business_Unit__c)+'&00N20000001kXCR='+replaceStr(userData.User_Subdivision__c)+'&00N20000001kXCQ='+replaceStr(userData.User_Division__c)+'&what_id='+ what_id +'&who_id='+ who_id;      
      

        PageReference r= new PageReference(str);
        r.setRedirect(true);
        return r;
        
        }
    public String replaceStr(String s){
        if(s==null) s='';
        return s.replace('&', '%26');
    }
    
    public static testMethod void test()
    {
        Task t = new Task();
        Apexpages.Standardcontroller stdController = new Apexpages.Standardcontroller(t);
        TaskRedirectController testClass = new TaskRedirectController(stdController);
        System.assert(testClass.redirect() != null);
        System.assert(testClass.replaceStr(null) != null);
        System.assert(testClass.replaceStr('&') == '%26');
    }    
}


Many thanks for your help.
Best regards,
Ludivine

Hi,

 

Please find the below code snippet.

I am using input fields on the VF page and they are required.

When I click on the Previous button instead of Save instead of navigating to the previous page it remains on the same page and show the error message for the required fields. I tried using action region but its not working. I have highlighted the Previous button code.

Please let me know what is going wrong.

 

<apex:page standardController="Molecule__c" recordSetvar="mol" extensions="AddProductController" tabStyle="Opportunity" id="page">

<style>
    .button{
             
        width:80px;         
    }
</style>

<script src="/soap/ajax/24.0/connection.js"></script>
<script src="{!URLFOR($Resource.jQueryFiles, 'js/jquery-1.4.4.min.js')}"/>
<script src="{!URLFOR($Resource.jQueryFiles, 'js/jquery-ui-1.8.7.custom.min.js')}"/>

<script type="text/javascript">

var j$ = jQuery.noConflict();

j$(document).ready(function(){
    
    var netBid = document.getElementById("page:form:opp:blockSec:table:netBidheader:sortDiv");             
    j$(netBid).css("color", "red");
    
    var volPack = document.getElementById("page:form:opp:blockSec:table:volPackheader:sortDiv");    
 
    j$(volPack).css("color", "red");
    
    var opPlan = document.getElementById("page:form:opp:blockSec:table:opPlanheader:sortDiv");         
    j$(opPlan).css("color", "red");

    var opDem = document.getElementById("page:form:opp:blockSec:table:opDemheader:sortDiv");         
    j$(opDem).css("color", "red");

    var probHead = document.getElementById("page:form:opp:blockSec:table:probheader:sortDiv");         
    j$(probHead).css("color", "red");
     
});        

function checkSave(){

    var buttonstatus =document.getElementById("page:form:opp:saveButton").disabled;
         
    if (buttonstatus == false) {

        var op = confirm("Please click \'Save\' before navigating to the next page else information will be lost.\nDo you want to continue ?");
        
        if(op){    

            return true;
             
        }else{
            
            return false;
        }       
    } 
}

function checkValues() {
    alert('inside 11'); 
    var tabl = document.getElementById('page:form:opp:blockSec:table');
    var l = tabl.rows.length;
    l = l - 1;
    
    document.getElementById("errorblock").innerHTML='';
    
    var errFlag = 0;    
    var errIncrFlag = 0;
    var errpWinFlag = 0;
    var errpQuanFlag = 0;
    
    for (i = 0; i < l; i++) {
    
        var salesprice = document.getElementById("page:form:opp:blockSec:table:" + i + ":salesprice").value;        
        var incrOP = document.getElementById("page:form:opp:blockSec:table:" + i + ":optionListOP").value;       
        var incrDF = document.getElementById("page:form:opp:blockSec:table:" + i + ":optionListDF").value;        
        var pWin = document.getElementById("page:form:opp:blockSec:table:" + i + ":probWin").value;
        var quantity = document.getElementById("page:form:opp:blockSec:table:" + i + ":quantity").value;
        
        document.getElementById("page:form:opp:blockSec:table:" + i + ":salesprice").style.border = "";
        document.getElementById("page:form:opp:blockSec:table:" + i + ":optionListOP").style.border = "";        
        document.getElementById("page:form:opp:blockSec:table:" + i + ":optionListDF").style.border = "";
        document.getElementById("page:form:opp:blockSec:table:" + i + ":probWin").style.border = "";
        document.getElementById("page:form:opp:blockSec:table:" + i + ":quantity").style.border = "";
                  
        if (salesprice == "" || salesprice == 0) {
            
            errFlag = 1;          
            document.getElementById("page:form:opp:blockSec:table:" + i + ":salesprice").style.border = "1px solid #FF0000";            
        }
        
        if (incrOP == "") {
            
            errIncrFlag = 1;          
            document.getElementById("page:form:opp:blockSec:table:" + i + ":optionListOP").style.border = "1px solid #FF0000";           
        }
        
        if (incrDF == "") {
            
            errIncrFlag = 1;          
            document.getElementById("page:form:opp:blockSec:table:" + i + ":optionListDF").style.border = "1px solid #FF0000";            
        }
        
        if (pWin == "" || pWin > 100) {
            
            errpWinFlag = 1;         
            document.getElementById("page:form:opp:blockSec:table:" + i + ":probWin").style.border = "1px solid #FF0000";                    
        }  
        
        if (quantity == "" || quantity == 0) {
            
            errpQuanFlag = 1;         
            document.getElementById("page:form:opp:blockSec:table:" + i + ":quantity").style.border = "1px solid #FF0000";                    
        }    
    }
    
    if (errFlag == 1){
        
        document.getElementById('errorblock').innerHTML = document.getElementById('errorblock').innerHTML +'<br/><font color="#CC0000" size=2 >\' Net Bidding Price \' should always be greater than zero.</font>';
    }
    
    if (errIncrFlag == 1){
    
        document.getElementById('errorblock').innerHTML = document.getElementById('errorblock').innerHTML +'<br/><font color="#CC0000" size=2 >\' Inc to Op Plan \' and \' Inc to Dem Forecast \' are required fields.</font>';
    }
    
    if ( errpWinFlag == 1){
    
        document.getElementById('errorblock').innerHTML = document.getElementById('errorblock').innerHTML +'<br/><font color="#CC0000" size=2 >\' Prob. to Win (%) \' can be 0 or less than 100.</font>';
    }
    
    if (errpQuanFlag == 1){
    
        document.getElementById('errorblock').innerHTML = document.getElementById('errorblock').innerHTML +'<br/><font color="#CC0000" size=2 >\'Volume in Packs\' should always be greater than zero.</font>';
    }
 
    if(errFlag == 1 || errIncrFlag == 1 || errpWinFlag == 1 || errpQuanFlag == 1){
        
        return false;    
    }
    
    if(errFlag == 0 && errIncrFlag == 0 && errpWinFlag == 0 && errpQuanFlag == 0){
        
        return true;    
    }
    
}

function showWarning() {

    var saveStatus =document.getElementById("page:form:opp:saveButton").disabled;
         
    if (saveStatus == false) {

        var val = confirm("Please click \'Save\' before exiting the wizard. Click \'Cancel\' to stay on the current page.\nDo you want to continue ?");
        
        if(val){    
            
            return true; 
        }else{
            
            return false;
        }       
    } 
}

</script>

<apex:form id="form">
<apex:pageBlock id="opp" title="Enter Product Details">

    <apex:pageBlockSection columns="1" id="blockSec">
        
        <div id="errorblock">
        </div>

        <apex:pageBlockTable value="{!inputProductsWrapper}" var="p" columns="7" id="table">
           
            <apex:column headerValue="Product">
                <apex:outputText id="proName" value="{!p.proName}"/>   
            </apex:column>
                        
            <apex:column headerValue="Catalog Price">
                <apex:outputText value="{!p.unitPrice}"/>
            </apex:column> 
            
            <apex:column headerValue="Net Bidding Price" id="netBid">
                <apex:inputField value="{!p.opLine.unitPrice}" id="salesprice" rendered="{!NOT(p.saved)}"/>
                <apex:outputLabel value="{!p.opLine.unitPrice}" rendered="{!p.saved}"/>
            </apex:column> 
            
            <apex:column headerValue="Volume in Packs" id="volPack">
                <apex:inputField value="{!p.opLine.quantity}" id="quantity" rendered="{!NOT(p.saved)}"/>
                <apex:outputLabel value="{!p.opLine.quantity}" rendered="{!p.saved}"/>
            </apex:column> 
            
            <apex:column headerValue="Inc to Op Plan" id="opPlan">
                <apex:selectList id="optionListOP" value="{!p.opLine.Incremental_to_Operating_Plan__c}" size="1" rendered="{!NOT(p.saved)}">
                    <apex:selectOption itemValue="" itemLabel="-None-"/>
                    <apex:selectOption itemValue="Yes" itemLabel="Yes"/>
                    <apex:selectOption itemValue="No" itemLabel="No"/>
                </apex:selectList>
                <apex:outputLabel value="{!p.opLine.Incremental_to_Operating_Plan__c}" rendered="{!p.saved}"/>
            </apex:column> 
            
            <apex:column headerValue="Inc to Dem Forecast" id="opDem">
                <apex:selectList id="optionListDF" value="{!p.opLine.Incremental_to_Demand_Forecast__c}" size="1" rendered="{!NOT(p.saved)}">
                    <apex:selectOption itemValue="" itemLabel="-None-"/>
                    <apex:selectOption itemValue="Yes" itemLabel="Yes"/>
                    <apex:selectOption itemValue="No" itemLabel="No"/>
                </apex:selectList>
                <apex:outputLabel value="{!p.opLine.Incremental_to_Demand_Forecast__c}" rendered="{!p.saved}"/>
            </apex:column> 
            
            <apex:column headerValue="Prob. to Win (%)" id="prob">               
                <apex:inputField value="{!p.opLine.Probability_to_Win__c}" id="probWin" rendered="{!NOT(p.saved)}"/>
                <apex:outputLabel value="{!p.opLine.Probability_to_Win__c}" rendered="{!p.saved}"/>
            </apex:column> 

        </apex:pageBlockTable>      
    </apex:pageBlockSection>    
    
    <div class="rolodex">
        <apex:commandLink styleClass="listItem" rendered="{!hasPreviousInputProduct}"/> 
        <apex:commandLink styleClass="listItem" action="{!previousInputProductList}" rendered="{!hasPreviousInputProduct}" onClick="return checkSave()"><span class="listItemPad">Previous</span></apex:commandlink> 
        <apex:commandLink styleClass="listItem" rendered="{!hasNextInputProduct}"/>
        <apex:actionRegion >  
        <apex:commandLink styleClass="listItem" action="{!nextInputProductList}" rendered="{!hasNextInputProduct}" onClick="return checkSave()"><span class="listItemPad">Next</span></apex:commandlink> 
        </apex:actionRegion>   
    </div>
    
    <table width="75%" style="text-align:center;">
        <tr>
            <td>
                <br/>     
                <apex:actionRegion > <apex:commandButton value="Previous" action="{!previousPageProduct}" styleClass="button" onClick="return checkSave()"/> </apex:actionRegion>                        
                <apex:commandButton value="Save" action="{!insertOppProducts}" disabled="{!NOT(saveEnabled)}" styleClass="button" id="saveButton" onclick="return checkValues();"/>
                <apex:commandButton value="Edit" disabled="{!saveEnabled}" styleClass="button" action="{!editOppProducts}"/>
                <apex:commandButton value="Cancel" rendered="{!hasNextInputProduct}" styleClass="button" action="{!cancelPage}"/> 
                <apex:commandButton value="Exit" rendered="{!NOT(hasNextInputProduct)}" styleClass="button" action="{!cancelPage}" onClick="return showWarning()"/> 
            </td>
        </tr>
    </table>    
    
</apex:pageBlock>
</apex:form>

</apex:page>

 

My apex code is given i want to display the value of include2 on button click it is not working.
with regards
Shine
  ------------Apex code---------
public string timestampValue{get;set;}
public new2(){
timeStampValue = 'm';
}
public void sendTimestamp()
{
    timestampValue='timestampValue--' + timeStampValue;
//system.debug('timestampValue' + timeStampValue);
}

}
------------Apex code---------
-------------javascript code---------
var include2='';
function showIndustriesId(theId,obj)
{
    if(obj.checked)
    {
        include2=include2.concat((','+theId));
        alert(include2);
    }
    else
    {
        include2=include2.replace((','+theId),'');
        alert(include2);
    }
}
function sendTimeStamp()
{
    var timeStamp=include2;
          sendTimeStamp(timeStamp);
}

-------------javascript code---------
-------------visual force---------
<apex:form >
  <apex:commandButton value="pass" onclick="sendTimeStamp()"/>
          <apex:actionFunction name="sendTimeStamp" action="{!sendTimeStamp}" >
    <apex:param name="x" value="" assignTo="{!timeStampValue}" />
</apex:actionFunction>
    </apex:form>
-------------visual force---------

i have a variable in java script--- include2  i want to take that value into apex code i have written some piece of code found from discussion form but its not working .please tell me why?
  ------------Apex code---------
public string timestampValue{get;set;}
public new2(){
timeStampValue = 'm';
}
public void sendTimestamp()
{
    timestampValue='timestampValue--' + timeStampValue;
//system.debug('timestampValue' + timeStampValue);
}

}
------------Apex code---------
-------------javascript code---------
var include2='';
function showIndustriesId(theId,obj)
{
    if(obj.checked)
    {
        include2=include2.concat((','+theId));
        alert(include2);
    }
    else
    {
        include2=include2.replace((','+theId),'');
        alert(include2);
    }
}
function sendTimeStamp()
{
    var timeStamp=include2;
          sendTimeStamp(timeStamp);
}

-------------javascript code---------
-------------visual force---------
<apex:form >
  <apex:commandButton value="pass" onclick="sendTimeStamp()"/>
          <apex:actionFunction name="sendTimeStamp" action="{!sendTimeStamp}" >
    <apex:param name="x" value="" assignTo="{!timeStampValue}" />
</apex:actionFunction>
    </apex:form>
-------------visual force---------