Ideas to change the price value using javascript on Trading View Order - javascript

I am working on order automation for Trading View.
Although I have been able to make some progress, changing the price for limit orders (as well as the quantity, any number) has been a challenge. I am able to change the value on the input but it doesn't really get updated in the app model (hence the buy button never reflects the change).
Any help will be highly appreciated.
Best

Sometimes the view of the value is not bidirectional connected to the hidden input field. Seems like the trading app is using some reactive framework, they usually integrate some UI components library, and those libraries hide the real input field in behind the beautiful mask of the ux oriented view on the front side.
Here you have 2 options
Try to set the value of hidden input field in behind the component and try to send the request to see if the new value is fetched, no matter if its visible on front or no
I think more user friendly option, to trigger the events on the HTML elements, this will require more research from your side to learn how to trigger events and check the results of those events step by steps. If you already know it then it will be fast.
For Example:
// Let's say pure js
// Keep in mind, id of element, not a hidden input field.
const dropdown = document.getElementById('idOfHTMLElement');
dropdown.click(); // After click the options of the dropdown should appear
const options = Array.from(document.getElementsByClassName('classNameOfDropDownOption'));
const desiredOption = options.find((option) => option.someConditionLikePriceOrSmthElse: boolean);
desiredOption.click();
// Something like this, not accurate code, please test and correct if you will use this

Related

get notes input control from timeline via javascript

I would like to be able to hook an onChange event for the default text input box for Notes in a Dynamics CRM timeline (activity feed). However, I am not allowed to manually pull it from the DOM incase breaking changes occur in the future so I was hoping I could find it as a control with fixed name, such as fsdyn_notesinput for example.
However I have been unable to retrieve the specific control I am after. I can find "Timeline" which I believe contains the text control I want but have failed to find a way to enumerate the timeline's children or anything like that.
The intention is for me to be able to live check what is being typed into the box to look for special terms such as tags and provide additional functionality. I am very new to Dynamics development so it may be I am approaching this all wrong!
Currently I have nothing to share other than the typescript timeline fetch, which works:
let test2 = executionContext.getFormContext().getControl("Timeline");
We are using the new unified interface in the cloud.
You cannot hook an event handler to Notes control events in a supported way.
Instead, you can keep a multiline textbox in the entity form & onChange can be triggered on that field - you can provide additional functionality from here. You can create a Note (annotation) record with the content in this multiline field on record save.
In case of Notes creation from activity feed anywhere outside the entity form like dashboard, you should try C# Plugin on Notes record creation.

Deal with input errors

I'm new to react native.
I need to create the front-end part of an app used to manage products. In this app, a specific screen lets users add a "new product".
I've almost finished the UI part, but I now need to show errors to the user when something is wrong with its input (a missing product ID, a description with less than 10 characters, etc.).
Here's my objective: when the user clics the "publish" button, I check all the inputs. If the input is ok -> nothing happens, if the input contains an error -> the field turns red.
To achieve this, I need to work with states. Here should be an example for the title:
style={[style.inputText, {color: this.state.titleColor}]}
And I can change the state.TitleColor if something is wrong with the title input.
The problem is that I don't want to create a specific state for each input (titleColor, IDColor, descriptionColor, etc.).
How can I do a common state for inputs that are correct, and an other state for inputs that are wrong? I thought of using an array (with inputCorrect:[] ;
InputWrong:[]), but I do not know exactly how to deal with it.
Can someone help me? Thanks.
I'd recommend using a form library to help you with state and validation. I personally like formik, but I've heard good things about react-final-form as well (both are compatible with React Native).
Libraries like this make it easier to manage validation and input state, because they manage the state for you and tell each of your fields whether they're valid or not (passing appropriate error messages if needed).
It's still up to you to build the UI that displays the errors, but having the logic taken care of is a huge help. The formik docs have some good examples showing you how you would achieve your goal of changing a field color to red if that field has errors.
There is a bit of a learning curve to understand how to use these libraries well, but it's well worth it in my opinion.

Dynamics CRM - Add/Remove events from a custom made settings page

Hi awesome developers,
Maybe someone can help or put me in the right direction. I want to create a settings page with a few yes/no options.
These settings need to enable or disable form events from different entities. First I was thinking about creating a new entity named foo_Settings with a few fields and yes/no options to trigger on change events. These events will then add or remove events from another entity.
After doing some research, I couldn't find any examples or cases or any info if this could be done through webservices.
I hope someone can help :)
Greets,
Yes, it is a common design pattern in CRM to have a settings/configuration-entity for storing settings such as this.
You can decide to either have one settings-record per organization, or maybe one settings-record per business unit if that suits your needs better. In this way you can have different configurations depending on the need of each business unit.
After creating the settings record and adding some boolean fields, you would write javascript that runs OnLoad of specific entities. This code would fetch the relevant settings-record, read the value of the relevant boolean-field and add a change listener depending on the value of the boolean by calling addOnChange().
After thinking about the settingspage and ways/solutions to create such functionality, there also was something that was itchy..
By creating a settings page and checking in the onload function of each entity with a fetch (odata call), this is not the most fastest or cleanest way. What if thousands of people are using a entity.. This will resulting that thousands of people will fetch.
So my solution will be:
Creating a settingspage (entity).. Onchange event of a setting will fire a odata call to set a record (true or false) on a hidden field in that entity..
In the onload of the entity I will check the value of that hidden field and do logic. This way I will prevent that there will be an Odata call every time the page loads..
Are there any other solutions?

DRY up ng-model

I have a small web-app that accepts input from a human to create search params. I'm using ng-model-options to debounce the ng-change function to execute the search.
I have small arrows next to the column names on the table that lets users sort (there are three icons - up-down, up, and down for the sort_field and sort_order displayed using ng-class) ; I would like to register a change on those and execute a search after a small delay using debounce. The problem is I'm not sure how use ng-model to bind the particular param to those icons. I don't want someone hammering on the sort icons and crashing the server or their browser.
What I would rather do is have one place on the page that says to watch the search_param object and fire a search 500 milliseconds after whenever it has changed. This way any of the input fields or sort selections would be called when a user is done editing them which triggers a function to send those params to the endpoint.
What is the strategy in AngularJS to do this? Right now all input fields bind a field in the search_param object and have ng-model-options to debounce on change. This is a lot of repeated code.
I recently answered someone regarding Tables and the amount of effort and work you have to put in to get very basic functionality (sorting,searching,pagination).
Why re-invent the wheel if there is a perfectly great library for you to use:
Angular-datatables
I posted a complete solution here for you to use pulling data from a json source: Ng-repeat trying to create a counter index
In your case you would need to go through the Server side processing documentation on Datatable's site to correctly format the data: https://datatables.net/manual/server-side

Django Admin disable field dynamically based on other selections

I've built a django model where the required fields change based upon the user's selection on other previous fields. Specifically, it is an event scheduling application where the options change based on choices the user makes.
Some combinations of fields are simply invalid, and I have the model set to check for those and not allow them. However, it is a bit confusing in the UI to figure out the right combinations. I would like the admin UI to help with this by hiding or disabling invalid fields as the user changes other fields.
For example, if the user chooses to make the event repeat weekly, I need to disable (or ideally remove) all of the daily and monthly fields and only show the weekly ones, such as day of week.
Also, if they go back and change it to daily, then the fields that are shown or enabled need to change to reflect that selection.
How would I set up the admin form so that this happens? I know this is doable through the DOM and javascript, but I am trying to determine if there is a mechanism for this built in to Django. I've been searching the Django docs, but I can't seem to find it.
Does anyone have an example showing how you have done similar things?
There's no build in solution.
Simple solution is to add custom JavaScript code to your admin. See the reference here. Simply add the js and css files to the Admin class and script the form in your custom js.
class ReportAdmin(admin.ModelAdmin):
class Media:
js = (
'frontend/js/jquery-1.6.1.min.js',
'frontend/js/jquery-ui.min.js',
'frontend/js/custom_js.js',
)

Categories