• TJMeadows
  • NEWBIE
  • 10 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 6
    Replies
Hello all,

With Salesforce's latest release, it appears to have broken file upload by guest users. I thought it was resolved with this ISSUE (https://trailblazer.salesforce.com/issues_view?id=a1p3A000001YpGnQAK) but that doesn't seem to apply to my problem.

I have a Salesforce Site that hosts a visualforce page to allow guest users to update a custom object record and attach a file, via the [New] button on the Attachments related list. Now, however, that upload attempt sends the user to the Unauthorized page. So, I swapped the related list for an apex:inputFile component. The mere existence of that component causes the Unauthorized page upon submission.

Here's a sample page:
<apex:page controller="customController" doctype="html-5.0" showheader="false" sidebar="false">

	<apex:outputpanel id="responsePnl">
	    <apex:form id="responseFrm">
	        <apex:pageblock id="responseBlock" mode="edit">
	            <apex:pageBlockButtons location="bottom">
	        		<apex:commandButton action="{!submitResponse}" value="Submit" rerender="responsePnl">
	        		</apex:commandButton>
	      		</apex:pageBlockButtons>
                <apex:inputFile value="{!att.body}" filename="{!att.name}"/>
            </apex:pageblock>            
	    </apex:form>
    </apex:outputpanel>
</apex:page>
and here's a sample controller:
public without sharing class customController{
    public Attachment att { get; set; }

	public customController() {
		att = new Attachment(ParentId = 'a5p030000008Opb');
	}

	public PageReference submitResponse() {
		if (att.Name != null) {
            insert att;
        }

        return null;
	}
}


If the inputFile is commented out, there are no issues submitting.
I've checked Files > General Settings > "Allow site gue users to upload files"
The Site Guest Profile has Modify All permissions to the custom object.
Secure Guest User Record Access has been enabled and disabled.
Sharing Setting created to enable Read access to the parent object.

Is there something I overlooked with the new Guest permission enforcement?

Other notes:
inputFile causes failed submission everytime.
Attachment related list fails after going through the file upload wizard
Attachment relate list will allow successful update to the custom object if no file upload is attempted.
 

Hello all,

I'm running into an error that just doesn't make sense to me. I have a trigger on OrderItem that evaluates related payments to an order to determine if it is paid off. The error claims that a change to the order currency is happening, but that is not the case. I've debugged the before and after object maps to verify that CurrencyIsoCode is unchanged.
 
Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, OrderItemTrigger: execution of AfterInsert
caused by: System.DmlException: Update failed. First exception on row 0 with id 8013D0000009C8hQAE; first error: FIELD_INTEGRITY_EXCEPTION, You can't edit the order currency when the order has order products.: Contract Currency: [CurrencyIsoCode]

Here is the trigger handler:
private void evaluatePaidOffStatus(List<OrderItem> orderItems) {
	if (shouldRun('evaluatePaidOffStatus')) {
		methodRunMap.put('evaluatePaidOffStatus', false);
		
		Set<Id> orderIds = new Set<Id>();
		for (OrderItem orderItem : orderItems) {
			orderIds.add(orderItem.OrderId);
		}
			
		OrderTransferService.evaluateOrderPayments(orderIds);
	}
}



and the erroring method:
public static void evaluateOrderPayments(Set<Id> orderIds) {
	Order[] orders = [select Id, Grand_Total__c, Paid_Off__c, (select Id, pymt__Amount__c from Payments__r) from Order where Id in :orderIds];// and Type != 'EDI'];
	for (Order order : orders) {
		Decimal amountPaid = 0.00;
		for (pymt__PaymentX__c payment : order.Payments__r) {
			amountPaid += payment.pymt__Amount__c;
		}

		order.Paid_Off__c = amountPaid >= order.Grand_Total__c;
	}
		
	update orders;
}

Thanks for any insight you all can give
 
I am attempting to programmatically archive Attachments in Salesforce over to Google Drive. Google Drive API requires OAuth and I am having a little bit of trouble setting it up.

I was trying to avoid building and parsing HTTP Requests/Responses in order to get through the Authorization Flow but my attempts have failed.

First, I configured an API Project via the Google API ConsoleUser-added image

Second, I created an AuthProvider in Salesforce.
User-added image

At this point, I would expect the following code sample to grab an Access Token for me:
system.debug(Auth.AuthToken.getAccessToken('0SO4B000000CacK', 'Open ID Connect'));
However, I receive a null value.

For good measure, duplicated everything for a Google Auth Provider, instead of  Open Id Connect with the same result. I also set up an external data source (which does authenticate and sync) to make sure I had a token.

Has anyone been able to successfully use AuthToken methods when connecting to Google APIs?
Is there anything that I missed along the way?
 
Hello community.

I'm trying to include PaymentConnect's payment terminal into a custom order wizard and have been following the supplied user guide.
Here's a snippet of the javascript to direct the user to the terminal:
goToPayment = function(){
	        	window.location = '/apex/pymt__PaymentTerminal?' +
	        		'csid={!quickOrder.BillToContactId}' +
	        		'&cancelURL=' + window.location +
	        		'&finishURL=' + window.location;
       		}

The issue I'm running into is that after clicking the Review Transaction button, all of the query parameters disappear. So after confirming the transaction on the next page, there is no finishURL to send the user back to the custom order wizard.

User-added image

User-added image

Has anyone else run into this issue?
I've got a requirement to automatically add a line item under certain circumstances, one being when new pricebook has been selected. Here's a very basic code snippet to reproduce what I'm seeing:
for(Opportunity oppt : Trigger.new){
    Opportunity oldOppt = Trigger.oldMap.get(oppt.Id);
    system.debug(oppt.Pricebook2Id);
    system.debug(oldOppt.Pricebook2Id);
.
.
.
}

Scenario 1: 
A pricebook is selected but there are 0 OpportuntityLineItem records. Click to change the selected Pricebook and save with the new selection.
The result is that the trigger recognizes the change in the Opportunity's Pricebook2Id.
11:22:48.106 (1136814371)|STATEMENT_EXECUTE|[11]
11:22:48.106 (1136937523)|USER_DEBUG|[11]|DEBUG|01s14000000O8KHAA0
11:22:48.106 (1136951905)|STATEMENT_EXECUTE|[12]
11:22:48.106 (1136994368)|USER_DEBUG|[12]|DEBUG|01sa0000000VjKKAA0

Scenario 2: 
A pricebook is selected but there is at least 1 OpportuntityLineItem record. Click to change the selected Pricebook and save with the new selection.
The result is that the trigger does not recognize the change in the Opportunity's Pricebook2Id.
11:19:54.624 (1650559414)|STATEMENT_EXECUTE|[11]
11:19:54.624 (1650693331)|USER_DEBUG|[11]|DEBUG|01sa0000000VjKKAA0
11:19:54.624 (1650703192)|STATEMENT_EXECUTE|[12]
11:19:54.624 (1650731617)|USER_DEBUG|[12]|DEBUG|01sa0000000VjKKAA0

Scenario 3: 
A pricebook is selected but there is at least 1 OpportuntityLineItem record. Manually delete the line item(s). Click to change the selected Pricebook and save with the new selection.
The result is that the trigger recognizes the change in the Opportunity's Pricebook2Id.​
12:50:21.992 (1017463572)|STATEMENT_EXECUTE|[11]
12:50:21.992 (1017568036)|USER_DEBUG|[11]|DEBUG|01sa0000000VjKKAA0
12:50:21.992 (1017578515)|STATEMENT_EXECUTE|[12]
12:50:21.992 (1017603260)|USER_DEBUG|[12]|DEBUG|01s14000000O8KHAA0

Has anyone ran acrossed this before? Does the automated deletion of line items interfere with the normal trigger flow?

 
Hello all,

With Salesforce's latest release, it appears to have broken file upload by guest users. I thought it was resolved with this ISSUE (https://trailblazer.salesforce.com/issues_view?id=a1p3A000001YpGnQAK) but that doesn't seem to apply to my problem.

I have a Salesforce Site that hosts a visualforce page to allow guest users to update a custom object record and attach a file, via the [New] button on the Attachments related list. Now, however, that upload attempt sends the user to the Unauthorized page. So, I swapped the related list for an apex:inputFile component. The mere existence of that component causes the Unauthorized page upon submission.

Here's a sample page:
<apex:page controller="customController" doctype="html-5.0" showheader="false" sidebar="false">

	<apex:outputpanel id="responsePnl">
	    <apex:form id="responseFrm">
	        <apex:pageblock id="responseBlock" mode="edit">
	            <apex:pageBlockButtons location="bottom">
	        		<apex:commandButton action="{!submitResponse}" value="Submit" rerender="responsePnl">
	        		</apex:commandButton>
	      		</apex:pageBlockButtons>
                <apex:inputFile value="{!att.body}" filename="{!att.name}"/>
            </apex:pageblock>            
	    </apex:form>
    </apex:outputpanel>
</apex:page>
and here's a sample controller:
public without sharing class customController{
    public Attachment att { get; set; }

	public customController() {
		att = new Attachment(ParentId = 'a5p030000008Opb');
	}

	public PageReference submitResponse() {
		if (att.Name != null) {
            insert att;
        }

        return null;
	}
}


If the inputFile is commented out, there are no issues submitting.
I've checked Files > General Settings > "Allow site gue users to upload files"
The Site Guest Profile has Modify All permissions to the custom object.
Secure Guest User Record Access has been enabled and disabled.
Sharing Setting created to enable Read access to the parent object.

Is there something I overlooked with the new Guest permission enforcement?

Other notes:
inputFile causes failed submission everytime.
Attachment related list fails after going through the file upload wizard
Attachment relate list will allow successful update to the custom object if no file upload is attempted.
 

Hello all,

I'm running into an error that just doesn't make sense to me. I have a trigger on OrderItem that evaluates related payments to an order to determine if it is paid off. The error claims that a change to the order currency is happening, but that is not the case. I've debugged the before and after object maps to verify that CurrencyIsoCode is unchanged.
 
Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, OrderItemTrigger: execution of AfterInsert
caused by: System.DmlException: Update failed. First exception on row 0 with id 8013D0000009C8hQAE; first error: FIELD_INTEGRITY_EXCEPTION, You can't edit the order currency when the order has order products.: Contract Currency: [CurrencyIsoCode]

Here is the trigger handler:
private void evaluatePaidOffStatus(List<OrderItem> orderItems) {
	if (shouldRun('evaluatePaidOffStatus')) {
		methodRunMap.put('evaluatePaidOffStatus', false);
		
		Set<Id> orderIds = new Set<Id>();
		for (OrderItem orderItem : orderItems) {
			orderIds.add(orderItem.OrderId);
		}
			
		OrderTransferService.evaluateOrderPayments(orderIds);
	}
}



and the erroring method:
public static void evaluateOrderPayments(Set<Id> orderIds) {
	Order[] orders = [select Id, Grand_Total__c, Paid_Off__c, (select Id, pymt__Amount__c from Payments__r) from Order where Id in :orderIds];// and Type != 'EDI'];
	for (Order order : orders) {
		Decimal amountPaid = 0.00;
		for (pymt__PaymentX__c payment : order.Payments__r) {
			amountPaid += payment.pymt__Amount__c;
		}

		order.Paid_Off__c = amountPaid >= order.Grand_Total__c;
	}
		
	update orders;
}

Thanks for any insight you all can give
 
I am attempting to programmatically archive Attachments in Salesforce over to Google Drive. Google Drive API requires OAuth and I am having a little bit of trouble setting it up.

I was trying to avoid building and parsing HTTP Requests/Responses in order to get through the Authorization Flow but my attempts have failed.

First, I configured an API Project via the Google API ConsoleUser-added image

Second, I created an AuthProvider in Salesforce.
User-added image

At this point, I would expect the following code sample to grab an Access Token for me:
system.debug(Auth.AuthToken.getAccessToken('0SO4B000000CacK', 'Open ID Connect'));
However, I receive a null value.

For good measure, duplicated everything for a Google Auth Provider, instead of  Open Id Connect with the same result. I also set up an external data source (which does authenticate and sync) to make sure I had a token.

Has anyone been able to successfully use AuthToken methods when connecting to Google APIs?
Is there anything that I missed along the way?
 
Hello community.

I'm trying to include PaymentConnect's payment terminal into a custom order wizard and have been following the supplied user guide.
Here's a snippet of the javascript to direct the user to the terminal:
goToPayment = function(){
	        	window.location = '/apex/pymt__PaymentTerminal?' +
	        		'csid={!quickOrder.BillToContactId}' +
	        		'&cancelURL=' + window.location +
	        		'&finishURL=' + window.location;
       		}

The issue I'm running into is that after clicking the Review Transaction button, all of the query parameters disappear. So after confirming the transaction on the next page, there is no finishURL to send the user back to the custom order wizard.

User-added image

User-added image

Has anyone else run into this issue?