Cannot find the code definition for "Email Purchase Order" Action In Purchase Order Screen - customization

I would like to Customize "Email Purchase Order" action in Action folder of Purchase Order Screen.
I don't find the code where it is located.
And suppose if it is presented in dll, Can we customize that?

I don't find the code where it is located.
It is not a standard action, some trickery is involved in the way it redirects the action.
It goes through the POOrderEntry.Action event handler first before it is routed to POOrderEntry.Notification event handler to send the email.
You can customize it by creating a graph extension on POOrderEntry and overriding the Notification method.
In the Notification method override you can use the condition adapter.Menu == "Email Purchase Order" to determine if the call to Notification method originated from the Email Purchase Order action menu item.

Related

Create complex order with Stripe payment

I am trying to allow my users to pay for their booking (for an event) on my website using Stripe. I've got most of the processing working well but I don't know how to connect the response I get from Stripe which indicates that the payment has been successful to my database so that it knows all the details required to make the booking.
In the standard situation of "buying X number of products", I know that I can create an order on the server which contains those details. Then I can put that order ID into the Stripe request and I can use that when the payment is successful to go and fulfil that order.
But in my case, I have to accept a load more information than that. Each booking can have multiple attendees attached to it - each attendee will have a name and load more information about them which needs to be used when the booking is created.
Is the only way to do this to add ALL of this attendee information in to the request to Stripe so that it can be used when the payment succeeds? Or is there another way?
If it helps to answer this question, I'm using Django on the backend.
The main way to achieve this is to:
Store the information related to the order in your own database with the corresponding payment intent ID (or checkout session ID).
Listen to the webhook event payment_intent.succeeded (or checkout.session.completed) to know when the payment is successful.
In the webhook event, get the payment ID with event.data.object.id and use that to look into your database to retrieve the information needed to fulfill the order.
You can learn more on how to fulfill orders in the Stripe documentation here.
Another option would be to use the metadata field of your payment intent (or checkout session) to directly store all the information related to the order. But I wouldn’t recommend this since it has some limitations (number of keys, length of values, etc.).

create facebook like notification system in django

Say user a liked user b. I want to show this as a notification in the notification panel of user b when she logs in. She can also view her previous notifications (basically like facebook notification). This is not email notification or a success/warning type one time notification.
I want to know the right track to follow. Do I use django-notifications or django-messages-framework or push notifications? Where is the use of channels and web sockets in all of these?
My steps:
1) create a notification app
2) create a notification model (what fields do I put here if since django-notification already has actor, verb, action object and target fields?)
3) Do i have to create forms.py? How is the notification message getting passed?
4) What view do I put in views.py? (please give an example code)
If there is any example project that implemented the notification system please provide a link.
If you're using django-notifications you can just create an object with the actor as user_a, verb as 'like' or any other action performed, recipient would be user_b
So something like
notify.send(request.user, verb='liked', recipient=[target_user])
When user_b logs in you can fetch all the notification (or maybe just the unread ones) and display it
user.notifications.active()
user.notifications.unread()

C++ Outlook MailItem replace body and discard on close

I have an addon in Outlook which adds warning to mailbody and links in the email when email is coming from external or untrusted sources.
Anyway, when I replace something in body, when email is opened in full view (no reading pane, double click full view of mail item), I hook mailItem close even and I discard changes, everything works well. (mailitem.onclose(olDiscard))
When I do this with reading pane on, when I discard the changes, Outlook still either saves the changes or when user is trying to close Outlook it asks user "Do you want to save changes to ....." and if user clicked on multiple emails during this period, it shows popup question for ALL emails user clicked and we replaced its body.
What's the solution here? What can I do to fix this? I want to make changes to link and to body, but discard them when user clicks away on another email. End goal is not having Outlook to ask user "Do you want to save changes ..." popups. Please advise.
I can't also make changes to inspector, because inspector is read-only.
P.S. plugin is written in C++.
The solution is to avoid modifying the message body if you do not want to keep the changes.
If you want to show a warning to the user, add a task pane to the inspector. Or simply stamp the message with a category - it will be shown in the inspector.
The Outlook object model doesn't provide anything for handling hyperlinks clicks. As a possible workaround you may consider implementing the following functionality:
When the item is selected or opened in Outlook you may replace the original URL with your own where you can pass the original URL as an encoded parameter if needed. So, if it is allowed to open the URL you can redirect the request further. Note, you can use the SelectionChange event of the Explorer class which is fired when the user selects a different or additional Microsoft Outlook item programmatically or by interacting with the user interface. This event also occurs when the user (either programmatically or via the user interface) clicks or switches to a different folder that contains items, because Outlook automatically selects the first item in that folder. However, this event does not occur if the folder is a file-system folder or if any folder with a current Web view is displayed.
Also you may consider handling the Open event of Outlook items which is fired when an instance of the parent object is being opened in an Inspector. When this event occurs, the Inspector object is initialized but not yet displayed. The Open event differs from the Read event in that Read occurs whenever the user selects the item in a view that supports in-cell editing as well as when the item is being opened in an inspector.
Another possible solution is to register a custom URL handler. So, basically, your registered application will be launched instead of a web browser where you can decide whether to launch a web browser and follow the URL or not. See Installing and Registering Protocol Handlers for more information.

How can I use FB.ui to post a user story?

Currently, the below FB.api function is invoked on a click event and posts a user story on the user's timeline (the FB app is in sandbox mode right now and the user story is still pending review):
FB.api( // creating the user story
'/userid/mynamespace:myaction',
'post',
{
myobject: fbObjectId, // retrieved in an earlier FB.api call
access_token: accessToken, // retrieved in an earlier FB.getLoginStatus call
message: customTextFromUser, // prefilled by my app (FB doesn't approve of this)
image: ImageURL, // prefilled by my app (FB is OK with this I think)
'fb:explicitly_shared': true // requires that I take the user out of the normal flow of the app which is why I want to show a modal first
},
function(response) {
// handle the response
console.log(response);
if (response.id) {
alert("Success! The user story has been shared on Facebook!");
} else {
alert("Woops! Something went wrong sharing the user story on Facebook. Please try again.");
}
}
);
What I think I need to do is show a modal dialog box such as in the case of when FB.ui is invoked to give the user an opportunity to add a User Message and then post the user story along with the User Message (if any).
Will I need to create my own custom modal dialog box or can I use FB.ui in some way to achieve this?
Note: The above API call works fine in my tests. Granted, variables such as mynamespace, myobject, and myaction have been obscured in the above code sample.
My real problem is the user story is just not being approved by Facebook because I supposedly need to "take the user out of the normal flow of the app" in order to Explicitly Share the user story with an additional optional User Message. I guess I need a strategy to address this issue rather than a specific code sample answer.
Here is the latest feedback I got from Facebook:
Your action doesn’t follow section IV.2 of the Platform Policies:
https://developers.facebook.com/policy/.
Words in the user message field must be manually written by the user
and can’t be pre-filled by the app, even if the user can edit or
delete the words. Learn more about user messages:
https://developers.facebook.com/docs/submission-process/opengraph/guidelines/action-properties/#usermessages.
Posting explicitly shared content needs to be optional for users. A
sharing control needs to be in-line whenever a user shares something
and it can’t be in a separate settings area. The content should have a
user-generated component or the user needs to be taken out of the
natural flow of the app in order to decide to publish the story back
to Facebook. Your current action integration shouldn’t be labeled as
“explicitly shared.” Learn more about explicitly shared content:
https://developers.facebook.com/docs/submission-process/opengraph/guidelines/action-properties/#explicitlyshared.
If you use a test user created for your App, or use your developer account, you should be able to see the story published before it's approved.
The API call you're making also needs to be updated slightly. Instead of using User ID in the FB.api, just use /me/mynamespace:myaction. The access_token also doesn't need to be included, as it's automatically passed by the call providing the user is logged in.
Finally, is your object actually called myobject? The name must match the settings you entered for your story, e.g. 'article` or another valid type.
To help debug the issue, try a simple API call first (e.g. remove message and image) and see what happens. Then add the other parameters back one by one to see which one is causing the issue.
Edit
To get the action approved, you need to make sure the user is entering a custom message in one form or another - usually via text input on the page. If you are sharing pre-defined text the user hasn't entered, facebook won't approve it.
If you want to share a pre-written message, it might be better to share it in another way, like a caption in the story itself.

How can I store the number of facebook Likes of a particular url in my own database?

Lets say I am having 5 news articles on my website and 2 registered users. Each news article is having an FB like button. I want to insert the username and article name in my own database whenever the user likes one of the articles. How can this be done?
If it would have been a normal submit button (instead of FB like button) then i would have simply added an onclick event to call a javascript function which in turn sends an ajax request to a php file which inserts the row in the database with the required field.
Can I add an onClick event with FB like button? if not then is there an alternative?
A slightly hack-y way to go about it would be to attach an onclick event handler to the iframe container to trigger an event whenever a user clicks like on page.
I haven't worked with the API that much, but can't you use this: edge.create -- fired when the user likes something (fb:like)? http://developers.facebook.com/docs/reference/javascript/FB.Event.subscribe/