• Nitin Paliwal 9
  • NEWBIE
  • 30 Points
  • Member since 2015

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 7
    Replies
I am using this code to return the first three letters of a Custom Object's id, so that I can then bypass the standard object landing page and go straight to a list view of that Custom Object:
 
//This class is used as a controller for allowing the Corporate Statements tab to land directly on the List View

public class PageRef{
public PageReference exit(){
//change the Any_ObjectName__c with your Custom or Standard Object name.
Schema.DescribeSObjectResult anySObjectSchema = Corporate_Statements__c.SObjectType.getDescribe();
String objectIdPrefix = anySObjectSchema.getKeyPrefix();
PageReference pageReference = new PageReference('/'+objectIdPrefix+'/o');
pageReference.setRedirect(true);
return pageReference;
}
}

I am not clear exactly how I am meant to now call this into a VisualForce page:
 
<apex:page controller="PageRef">
action = "{!URLFOR(pageReference)};
</apex:page>
Any help?
 
Hi All,

       I am getting page is blank, while click the login button.I didn't get any error before saving the code. While loging the page, it will be blank page

VF CODE :

<apex:page controller="Sample" sidebar="false" >
<apex:form >
<apex:pageBlock >

    <br>UserName&nbsp;<apex:inputText label="center" value="{!userName}"/></br>
    <br>Password &nbsp;&nbsp;<apex:inputsecret value="{!password}"/></br>    
    <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <apex:commandButton value="Login" action="{!loginPage}" reRender="Error"/></br>
    <br><br>
    <apex:outputLink value="https://c.ap2.visual.force.com/apex/RegistrationPage">Create New Account</apex:outputLink>
    </br></br>
    <apex:pageMessages id="Error"></apex:pageMessages>
    
</apex:pageBlock>
</apex:form>
</apex:page>





Controller :

public class Sample {     
    public String userName{get;set;}
    public String password{get;set;}
    public List<Registration__c> returns {get;set;}
   
    public Sample(){
   
      returns = new List<Registration__c>();
    }  
   
    public PageReference loginPage(){
   
        returns = [select ID, Name, User_Name__c, Password__c from Registration__c Where User_Name__c=:userName and Password__c=:password];
        if(!returns.isEmpty()) {
            Pagereference pr = new PageReference('/'+returns[0].id);
            pr.setReDirect(false);
            return pr;
        }
        else {
                ApexPages.addmessage(new ApexPages.message(ApexPages.severity.WARNING,'Invalid UserName or Password'));
                return null;
        }
        //Pagereference pr = new PageReference('/'+returns[0].Id);
        //pr.setRedirect(true);
        //return pr;
        return null;
    }

}

Plead Identify the error, what is missing here.

Thanks in advance
Thulasi
 
I am using this code to return the first three letters of a Custom Object's id, so that I can then bypass the standard object landing page and go straight to a list view of that Custom Object:
 
//This class is used as a controller for allowing the Corporate Statements tab to land directly on the List View

public class PageRef{
public PageReference exit(){
//change the Any_ObjectName__c with your Custom or Standard Object name.
Schema.DescribeSObjectResult anySObjectSchema = Corporate_Statements__c.SObjectType.getDescribe();
String objectIdPrefix = anySObjectSchema.getKeyPrefix();
PageReference pageReference = new PageReference('/'+objectIdPrefix+'/o');
pageReference.setRedirect(true);
return pageReference;
}
}

I am not clear exactly how I am meant to now call this into a VisualForce page:
 
<apex:page controller="PageRef">
action = "{!URLFOR(pageReference)};
</apex:page>
Any help?
 
Hello,

I was following the section in the trailhead as below:
Developer Beginner-->Data Modeling-->Creating Object Relationships-->Creating a Master-Detail Relationship

After creating the multilevel master-detail relationships as below:
1, one candidate can have one or more job applications
2, one job application can have one or more reviews

I tried to created another relevant master-detail relationship as below:
3, one position can have one or more job applications

But it's not feasible, and the field type-->Master-Detail Relationship has information as below:
You cannot create this type of field because a master-detail relationship already exists on this object, and this object is the master in another master-detail relationship.

Can anyone adivse is it possible to create the relationship 1,2 and 3 above?
If not possible, any equivalent substitution?

Thank you in advance.

Burt



 
I developed a trigger firing after inserting records in the ContentDocumentLink object.
You can find the code here: http://nopaste.linux-dev.org/?780808.

The trigger works just fine but I have a problem with the testing class I wrote for it: http://nopaste.linux-dev.org/?780809

As you can see there is an insert for the object checked by the trigger.
When I run the test class I don't receive any error but the coverage is stuck at 0% no matter what I try to do. It seems like the trigger is not fired at all.

I suppose I'm making a mistake somewhere but I don't know where...

Can you guys guve me any hint?

Thanks,
Giovanni