• Steven Berg 5
  • NEWBIE
  • 0 Points
  • Member since 2017
  • jamata123@yahoo.com

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 6
    Questions
  • 0
    Replies
I have a trigger on the contact object that checks if the phone field is updated using trigger.oldmap.get(phone)/ trigger.newmap.get(phone)
I would like to take that value say  newphonenumber and pass that value as a parameter to a javascript function where I can do a ajax jquery put call. If someone has a code example i would appreciate it. Thank You

Here is some psuedo code of what I would like to do:

trigger CheckPhoneNumberChanged on Contact (before update) {
If (trigger.oldmap.get(phone) != trigger.newmap.get(phone) )
                       newphonevalue= trigger.newmap.get(phone);
}
// call javascript function 
function passPhonevalue(newphonevalue) {

 type: "PUT",
data: { "Phone":newphonevalue }
                                                                      }

 
I am passing a pdf file to Javascript.
It converts the file to a string using  readAsDataURL.
When I  attempt to pass this to a string in the apex controller it shows it as [objetc file] not as a base64 string.
How do I take the javascript base64 string and pass it to apex so it shows as a base64 string?

For example In javascript I have a variable mydoc.
mydoc shows AAAAGHV/LOP which is a base64 string
when I pass this using apex param actionFunction the apex string shows [object file]
I would like it to show the same value as the javascript variable which is AAAAGHV/LOP
I have a visualforce page using a repeat (c variable)
I am trying to update the inputtext value = "{!c.name}" 

if the value is  Bob, I want to change it to Jim via an input field and have Jim passed  as a value to my controller .
When I hit the custom Submit button which is a page reference on my controller
Bob is passed to the controller not Jim.

Do I need to do something in the code  so a setter is fired or some kind of page refresh? Thank You

<label style="padding-Right:20px" >Account Name:</label>
 <apex:actionRegion>
 <apex:inputtext label="Account Name:" value="{!c.Name}" id="AccountNameId">
 <apex:actionSupport event="onchange"
       action="{!doActionSupport}"
       reRender="refresh">
<!-- <apex:param value="{!c.name}" Name="myName" assignto="{!myName}"/> -->
<apex:param value="{!c.name}" Name="myName" assignto="{!myName}"/>
 </apex:actionSupport>
 </apex:inputtext>
 </apex:actionRegion>


Controller code:
public PageReference doActionSupport() {
      
    system.debug('doActionsupport activated ' );
    
    String myBigName = ApexPages.currentPage().getParameters().get('myName');
    
    
    System.debug('myBigName in doActionSupport is ' + myBigName); // Shows Bob not Jim
    System.debug('myName in doActionSupport is ' + myName); // Shows Bob not Jim
    
  
    return null;

my VF page:

<label style="padding-Right:20px" >Account Name:</label>
 <apex:actionRegion>
 <apex:inputtext label="Account Name:" value="{!c.Name}" id="AccountNameId">  // c.Name has been changed form Bob to Jim on the vf page
 <apex:actionSupport event="onchange"
       action="{!doActionSupport}"
       reRender="refresh">
<apex:param value="{!c.name}" Name="myName" assignto="{!myName}"/>  // myName has the old value of Bob not the new value of Jim
 </apex:actionSupport>
 </apex:inputtext>
 </apex:actionRegion>
 
I want to Display the following List returned from a json deserialize list.
I can get it working as a regular list from Soql but not from Json.

 Basic =    (List<fromJSONMemberInfoBasic>)JSON.deserialize(text1, List<fromJSONMemberInfoBasic>.class);
 
I get the following error on my VF page:
         Error: Unknown property 'fromJSONMemberInfoBasic.AccountContactRelations.Contact'
This is based on a subquery which queries AccountContactRelations

         My VF code is the following:
 
I can display The Values in Account but not in AccountContactRelations
 <apex:pageblockTable value="{!Basic}" var="b">
 
 <apex:column headerValue="Name" value="{!b.Name}"/> 
  <apex:column headerValue="Id" value="{!b.Id}"/>
    
                 <apex:pageblockTable value="{!b.AccountContactRelations}" var="c">
                  <apex:column headerValue="Account Name"> 
                <apex:inputText value="{!c.Contact.Name}" Rendered="{!c.Contact.Cardholder_Type__c=='Primary'}"/>
                </apex:column>
                   </apex:pageblockTable>
   </apex:pageblockTable>
  
Basic is the following list:

 Basic [fromJSONMemberInfoBasic:[AccountContactRelations=AccountContactRelations:[done=true, records=(Records:[Account=Account:[Id=001M000000xMs8VIAS, Name=Account001, attributes=Attributes:[type_Z=Account, url=/services/data/v39.0/sobjects/Account/001M000000xMs8VIAS]], AccountId=001M000000xMs8VIAS, Contact=Contact:[AccountId=001M000000wmnzIIAQ, CardholderType=Authorized, CitySecondary=NY, Email=mccoy3@aol.com, Id=003M000000wPPVYIA4, Name=Leonard McCoy3, StateSecondary=NY, ZipCodeSecondary=10013, attributes=Attributes:[type_Z=Contact, url=/services/data/v39.0/sobjects/Contact/003M000000wPPVYIA4]], ContactId=003M000000wPPVYIA4, Id=07kM0000000Cg3TIAS, attributes=Attributes:[type_Z=AccountContactRelation, url=/services/data/v39.0/sobjects/AccountContactRelation/07kM0000000Cg3TIAS]], Records:[Account=Account:[Id=001M000000xMs8VIAS, Name=Account001, attributes=Attributes:[type_Z=Account, url=/services/data/v39.0/sobjects/Account/001M000000xMs8VIAS]], AccountId=001M000000xMs8VIAS, Contact=Contact:[AccountId=001M000000wmnzIIAQ, CardholderType=Primary, CitySecondary=NY, Email=bones@starfleet.org, Id=003M000000wPPXjIAO, Name=Leonard2 McCoy2, StateSecondary=NY, ZipCodeSecondary=10013, attributes=Attributes:[type_Z=Contact, url=/services/data/v39.0/sobjects/Contact/003M000000wPPXjIAO]], ContactId=003M000000wPPXjIAO, Id=07kM0000000CuNrIAK, attributes=Attributes:[type_Z=AccountContactRelation, url=/services/data/v39.0/sobjects/AccountContactRelation/07kM0000000CuNrIAK]], Records:[Account=Account:[Id=001M000000xMs8VIAS, Name=Account001, attributes=Attributes:[type_Z=Account, url=/services/data/v39.0/sobjects/Account/001M000000xMs8VIAS]], AccountId=001M000000xMs8VIAS, Contact=Contact:[AccountId=001M000000xMs8VIAS, CardholderType=Authorized, CitySecondary=NY, Email=test@org.com, Id=003M000000wQ9b8IAC, Name=Test Rest, StateSecondary=NY, ZipCodeSecondary=07654, attributes=Attributes:[type_Z=Contact, url=/services/data/v39.0/sobjects/Contact/003M000000wQ9b8IAC]], ContactId=003M000000wQ9b8IAC, Id=07kM0000000CtOqIAK, attributes=Attributes:[type_Z=AccountContactRelation, url=/services/data/v39.0/sobjects/AccountContactRelation/07kM0000000CtOqIAK]]), totalSize=3], Basic=null, Id=001M000000xMs8VIAS, Name=Account001, attributes=Attributes:[type_Z=Account, url=/services/data/v39.0/sobjects/Account/001M000000xMs8VIAS], text1=null, text2=null]]
 
I have the following Soql call in my controller:

public  with sharing class getAccountContactRelations {

public static list<account> getAccounts() {

  LIST <Account> MemberInfo = [SELECT Id, Name,  (SELECT Id,Contact.Name,Contact.Cardholder_Type__c,Contact.AccountId,
                                             Contact.email,Contact.MailingAddress,Contact.City_Secondary__c,Contact.Zip_Code_Secondary__c,Contact.State_Secondary__c,
                                             Contact.MobilePhone,Account.name
 FROM AccountContactRelations where Contact.Cardholder_Type__c = 'Authorized' Or Contact.Cardholder_Type__c = 'Primary' ) 
 FROM Account WHERE Id = '001M000000xMs8V'];

                                                                                                     
                                                   return MemberInfo;
                                          
                                            }       
                 }



My Visualforce page has the following code:

<apex:page controller="getAccountContactRelations">

<apex:pageblock>
<apex:pageblockTable value="{!Accounts}" var="a"> 
<apex:pageblockTable value="{!a.AccountContactRelations}" var="r">

<apex:column headerValue="City" value="{!r.Contact.City_Secondary__c}"/>

</apex:pageblockTable>
</apex:pageblockTable>

</apex:pageblock>
</apex:page>

The Object has values but they are not being displayed on the Visualforce page.
How should my visualforce page be coded so I can see the results of my subquery?
Thank you
I am using Javascript remoting and after inserting a record would like to redirect the user to a new visualforce page
that displays the message "Contact record inserted".

Here is a snippet of my code:
In My Visualforce Page:

'{!$RemoteAction.AddUserWizardControllerExt.AddUser}',
 txtCardHolderFirstName,txtCardHolderLastName,txtCardHolderDob,txtCardHolderCity,txtCardHolderState,txtCardHolderZipCode,
 txtCardHolderType,recordid,
                      function(result, event) {
                        if (event.status) {

In My controller: After inserting a record would like to redirect the page with parameters being passed.

@RemoteAction
  global static PageReference AddUser(String txtCardHolderFirstName, String txtCardHolderLastName,
  String txtCardHolderDob, String txtCardHolderCity, String txtCardHolderState,
  String txtCardHolderZipCode, String txtCardHolderType, String recordid) {
                                                 
                                              /* record gets inserted with passed arguments */
                                             /* would like to redirect the user  to a Visualforce page */
                                                 

Pagereference pg = new Pagereference('/apex/AddUserWizardConfirmation');
                                                  pg.getParameters().put('id',CurrentContactId);
                                                  pg.getParameters().put('NewCardHolderId',NewCardHolderId);
                                                  pg.getParameters().put('NewCardHolderFirstName',NewCardHolderFirstName);
                                                  pg.getParameters().put('NewCardHolderLastName',NewCardHolderLastName);
                                                  pg.getParameters().put('NewCardHolderSalutation', NewCardHolderSalutation);
                                                 
                                                 system.debug('Msg in Add User Wizard is ' + Msg);
                                                   pg.getParameters().put('Msg',Msg);
                                                 
                                                 pg.setredirect(true);