-
ChatterFeed
-
0Best Answers
-
0Likes Received
-
0Likes Given
-
3Questions
-
2Replies
Apex:InputFile not returning data to controller on first use. Works after that.
I am having a really weird issue with apex:InputFile. I hide it until the user clicks on a button. When I show it the first time and do a save, nothing goes back to the controller. The value of my Blobs are null.
If I show it again and pick a file it works fine.
I added a text field to my dialog for testing purposes. The text box always works. The inputFile never works on the first call, but works fine after that. Any suggestions on what I need to change
Here is the markup for my dialog with the Apex:InputFiles
<apex:outputPanel id="UploadPicture">
<apex:outputPanel rendered="{!ShowUploadPicture}" layout="block" styleClass="SaveModal">
<div class="dmodal" id="pictureModal" tabindex="-1" role="dialog" >
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content opaque">
<div class="modal-header">
<h1 class="modal-title">Upload Files</h1>
</div>
<div class="modal-body">
<apex:actionRegion >
<apex:inputText value="{!DummyText}" label="Dummy Text"/>
<apex:outputPanel layout="block" styleclass="panel panel-default" style="margin:20px;" >
<apex:outputpanel layout="block" styleclass="panel-body">
<div class="col-xs-12 col-sm-12 col-md-12 text-center">
<H4>Inside Store Photo</H4>
<div class="row" style="height:120px;">
<apex:outputPanel styleclass="glyphicon glyphicon-ok-circle upOk" html-aria-hidden="true" rendered="{!NOT(ISNULL(InsideStorePhoto.Id))}"></apex:outputPanel>
<apex:image url="{!URLFOR($Resource.rvie_img_place)}" height="100" alt="" rendered="{!ISNULL(InsideStorePhoto.Id)}" />
<apex:image url="{!URLFOR($Action.Attachment.Download, InsideStorePhoto.Id)}" height="100"
html-onerror="this.src='{!$Resource.no_preview}'" alt="Preview not supported" rendered="{!NOT(ISNULL(InsideStorePhoto.Id))}"
onclick="window.open('{!URLFOR($Action.Attachment.Download, InsideStorePhoto.Id)}','_blank','toolbar=yes, scrollbars=yes, resizable=yes');" />
</div>
<apex:outputPanel layout="block" styleclass="row" >
<label class="btn btn-default btn-file">
Select a Picture<apex:inputfile value="{!IBody}" contentType="image" filename="{!InsideStoreBody.Name}" onchange="previewFileAll(this)" style="display:none;"/><!----->
<br/>{!InsideStoreBody.Name}
</label>
</apex:outputPanel>
</div>
</apex:outputpanel>
</apex:outputPanel>
<apex:outputPanel layout="block" styleclass="panel panel-default" style="margin:20px;" >
<apex:outputpanel layout="block" styleclass="panel-body">
<div class="col-xs-12 col-sm-12 col-md-12 text-center">
<H4>Overall Photo</H4>
<div class="row" style="height:120px;">
<apex:outputPanel styleclass="glyphicon glyphicon-ok-circle upOk" html-aria-hidden="true" rendered="{!NOT(ISNULL(OverallPhoto.Id))}"></apex:outputPanel>
<apex:image url="{!URLFOR($Resource.rvie_img_place)}" height="100" alt="" rendered="{!ISNULL(OverallPhoto.Id)}" />
<apex:image url="{!URLFOR($Action.Attachment.Download, OverallPhoto.Id)}" height="100"
html-onerror="this.src='{!$Resource.no_preview}'" alt="Preview not supported" rendered="{!NOT(ISNULL(OverallPhoto.Id))}"
onclick="window.open('{!URLFOR($Action.Attachment.Download, OverallPhoto.Id)}','_blank','toolbar=yes, scrollbars=yes, resizable=yes');" />
</div>
<apex:outputPanel layout="block" styleclass="row" >
<label class="btn btn-default btn-file">
Select a Picture<apex:inputfile value="{!OBody}" contentType="image" filename="{!OverallBody.Name}" onchange="previewFileAll(this)" style="display:none;" /><!----->
<br/>{!OverallBody.Name}
</label>
</apex:outputPanel>
</div>
</apex:outputpanel>
</apex:outputPanel>
<apex:outputPanel layout="block" styleclass="panel panel-default" style="margin:20px;" >
<apex:outputpanel layout="block" styleclass="panel-body">
<div class="col-xs-12 col-sm-12 col-md-12 text-center">
<H4>Restroom Photo</H4>
<div class="row" style="height:120px;">
<apex:outputPanel styleclass="glyphicon glyphicon-ok-circle upOk" html-aria-hidden="true" rendered="{!NOT(ISNULL(RestroomPhoto.Id))}"></apex:outputPanel>
<apex:image url="{!URLFOR($Resource.rvie_img_place)}" height="100" alt="" rendered="{!ISNULL(RestroomPhoto.Id)}" />
<apex:image url="{!URLFOR($Action.Attachment.Download, RestroomPhoto.Id)}" height="100"
html-onerror="this.src='{!$Resource.no_preview}'" alt="Preview not supported" rendered="{!NOT(ISNULL(RestroomPhoto.Id))}"
onclick="window.open('{!URLFOR($Action.Attachment.Download, RestroomPhoto.Id)}','_blank','toolbar=yes, scrollbars=yes, resizable=yes');" />
</div>
<apex:outputPanel layout="block" styleclass="row" >
<label class="btn btn-default btn-file">
Select a Picture<apex:inputfile value="{!RBody}" contentType="image" filename="{!RestroomBody.Name}" onchange="previewFileAll(this)" style="display:none;"/><!----->
<br/>{!RestroomBody.Name}
</label>
</apex:outputPanel>
</div>
</apex:outputpanel>
</apex:outputPanel>
<!-->/div>
<div class="modal-footer"-->
<apex:commandbutton value="Save" action="{!SavePicture}" /> <!--reRender="UploadPicture, pbTable"/-->
<apex:commandbutton immediate="true" html-data-dismiss="modal" value="Cancel" action="{!HidePicture}"/> <!--reRender="UploadPicture, pbTable"/-->
</apex:actionRegion>
</div>
</div>
</div>
</div>
</apex:outputPanel>
</apex:outputPanel>
Is there anything I need to do with my Blob Variables before my first call to make this work on the first time.
-
- Joe Briatico
- March 12, 2018
- Like
- 0
- Continue reading or reply
User field level security standard fields
Trying to develop a visual force page that will display user information. Some of the information (About Me and profile pic) do not show up on the page when I test the website. Shows up when I run in test mode (/apex/pagename), This is usually a field level security issue.
The problem that I face is field level security is not available for standard fields on the user object. Is there a workaround? How can I see those fields on the page?
Thanks,
Joe
-
- Joe Briatico
- April 19, 2016
- Like
- 0
- Continue reading or reply
Chatter Rest API and authorization confusion
I want to use the Chatter Rest API from a visualforce page since the ConnectAPi won't work for guest users
I created a connected app in a dev environment.
I am able to get an access token as long as I use the dev login that I used to create the connected app. I can't use a login from the sandbox instance that I am using. Is there a way to do so
Then I try running the following function
public ChatterUser getChatterUser(string userId){
String endpoint;
version = '/services/data/v36.0';
instanceUrl = System.Url.getSalesforceBaseUrl().toExternalForm();
endpoint= instanceUrl + version + '/chatter/users/' + userId;
HttpRequest req = new HttpRequest();
req.setEndpoint(endpoint);
req.setMethod('GET');
req.setHeader('Content-type', 'application/json');
req.setHeader('Authorization', 'Bearer ' + accessToken);
HTTP http = new HTTP();
HTTPResponse resp = http.send(req);
System.Debug('Response:' + resp);
System.Debug('Response Body:' + resp.getBody());
}
and I get the following error
[Status=Unauthorized, StatusCode=401]
{"message":"Session expired or invalid","errorCode":"INVALID_SESSION_ID"}
Can anyone see what I am doing wrong? It is kind of weird that I use a dev user and try to access data data from a sandbox instance. Does the authenticated user need Chatter access? Is there a way that I can use a production user to authenticate?
-
- Joe Briatico
- April 13, 2016
- Like
- 0
- Continue reading or reply
REST API calls from C# return "Not Authorized" (401) status.
I am developing a Windows forms application in C# that will use the REST Analytics API to capture report information. I am using the OAuth 2.0 User Agent flow to obtain an authentication token. I have registered my app as a Connected App, with a callback URI of sfrr:oauth2. I monitor the URLs during authentication and intercept any calls to that uri. In the Connected App setup, I selected "full" and "refresh_token, offline_access" as OAuth Scopes.
After some initial difficulty, I am now regularly receiving my access token. However, when I tried to use that token to retreive a report, I got the 401 status (Not Authorized). At that point, I went back to the sample queries from the REST API Developer's Guide and started excuting them. The first query in the form <instance_url>/services/data/ returns a list of API versions, as expected. The next call is to <instance_url>/services/data/v34.0/. I should get a list of available resources, but I get the Not Authorized response instead. I am passing my access token in the request header using "Authorization:Bearer <access token>" and <instance_url> is the URL returned iin my OAuth User Agent results.
I saw -- once and could not find it again -- a forum response that gave the name and email address for a contact in Salesforce if your organization cannot access even though access should otherwise be available. Is that still a problem? Is there somethig else I'm missing here? Suggestions and enlightenment gratefully accepted.
- Chuck Ramsey
- October 02, 2015
- Like
- 0
- Continue reading or reply
Can we call web services through trigger?
Can we call web services through trigger?
- anvesh@force.com
- March 28, 2013
- Like
- 0
- Continue reading or reply