How to get the Title of a dynamic page during form submission in Wix Database - velo

I have made dynamic pages for my recipes in Wix and I had an user form for feedback in the dynamic pages , I'm able to get the feedback but can't able to know for which item they are ?
I want to get the title of recipe along with the user feedback into
my database.
Please help me solve it.

You can get information from the Dynamic Dataset like this:
var myVariable;
$w("#dynamicDataset").onReady( () => {
let itemObj = $w("#dynamicDataset").getCurrentItem();
myVariable = itemObj.fieldKey; //get the relevant field key
});
After this you can submit the data using the Wix Data API. Just make sure to pass on the myVariable so that you know where the submission came from. Sample code below.
let data = {
fieldKey1: randomVariable,
fieldKey2: someVariable,
pageInfo: myVariable
}
wixData.insert('collectionName', data);
Read more about dynamic dataset's getCurrentItem() function here: https://www.wix.com/corvid/reference/wix-dataset.DynamicDataset.html#getCurrentItem
Also, the submission has to go through using the Wix Data API's insert() function. Read about it here: https://www.wix.com/corvid/reference/wix-data.html#insert

Related

Passing data from blade to blade in Laravel

I have a page where you can create your workout plan. Second page contains "pre-saved" workouts and I want them to load by passing parameters from second page to first. If you directly access first page, you create your workout plan from scratch.
// first page = https://prnt.sc/y4q77z
// second page = https://prnt.sc/y4qfem ; where you can check which one you want to pass to first page
// final step looks like this: https://prnt.sc/y4qh2q - but my URL looks like this:
www.example.com/training/plan?sabloni%5B%5D=84&sabloni%5B%5D=85&sabloni%5B%5D=86
this 84,85,86 are IDS
Can I pass params without changing URL ? Like having only /training/plan without anything after ?
public function plan(Request $request){
$workout = false;
if($request->workout){
$workout = $request->workout;
$workout = SablonTrening::find($sabloni); // $workout = array [1,3,4,5,6]
}
return view('trener.dodaj_trening', compact('workout'));
}
If you are getting to the /training/plan page with GET request, you could simply change it to POST. That way the parameters would be hidden in the URL but would be present in the request body. You would need a new post route:
Route::post('/training/plan', 'YourController#plan')->name('training.plan');
And then, in the form where you are selecting these plans, change the method on submit:
<form action="{{route('training.plan')}}">
//Your inputs
</form>
Your method should still work if your inputs stay the same.
Note: Not sure you would still keep the functionalities that you need, since I can't see all the logic you have.
If you have any questions, let me know.
To pass data from on blade to another blade.
At the end of first post before redirect()-route('myroute') add $request->session()->put('data', $mydata);
At the begining of the route 'myroute', just get back your data with $data = $request->old('data');

how to use the expand parameter in Xrm.WebApi.retrieveRecord

I am using below scripts to get the reference entity from email entity. When the scripts was triggered, it prompts 'Could not find a property named 'new_queue' on type 'Microsoft.Dynamics.CRM.email''.
The reference entity's scheme name is new_queue, and I think the structure of the script is same as the guidance of microsoft knowledge article.
(https://learn.microsoft.com/en-us/powerapps/developer/model-driven-apps/clientapi/reference/xrm-webapi/retrieverecord)
Can anybody point out what's wrong here?
Xrm.WebApi.retrieveRecord("email", '4884f79f-42f3-ea11-a815-000d3a44afcc', "?$select=subject&$expand=new_queue($select=queueid,name)").then(
function success(result) {
var toLookup = new Array();
toLookup[0] = new Object();
toLookup[0].id = result.queueid;
toLookup[0].entityType = "queue";
toLookup[0].name = result.name;
alert(result.name);
}, function (error) {
Xrm.Utility.alertDialog(error.message);
});
This issue is usually an outcome of case sensitive schema name, try new_Queue instead of new_queue. You can always verify this by checking in xml metadata.
Update:
I remember that the activity (email, task, appointment, etc) is special and little different. Make sure you download the metadata xml from Developer resources and check the correct navigation property. It should look like email_new_queue or new_queue_email
To know the correct navigation property name to use it in $expand:
Request the "Email" entity and Include the following header Prefer: odata.include-annotations="*".
In the response, you should find a field that looks something like:
"_new_queue_value#Microsoft.Dynamics.CRM.associatednavigationproperty": "????"
Use the name you'll find in the place of "????" in the $expand expression.

How to disable a Dynamics CRM field when the value changes without breaking save?

We have a two state field called Primary that is set to either yes or no. When the field is set to no, the user should be able to change it to yes. When the field is set to yes, it should be disabled, so the user can no longer change it.
We have code in the onload event that handles this; that works just fine. The challenging case is the one where a user changes the field from no to yes and then saves the form. This should lock the field so the user can't change it back to no. We attempted to solve this by putting the following code in onsave event:
export function onSave() {
var primaryControl = Xrm.Page.getControl(
d.ConstituentAffiliation.AttributeNames.Primary.toLowerCase());
if (primaryControl) {
if (primaryControl.getAttribute().getValue()) {
primaryControl.setDisabled(true);
}
else {
primaryControl.setDisabled(false);
}
}
}
This partly works. It does disable the field so it can no longer be changed. The save doesn't work, however, because Dynamics CRM appears not to send the values of disabled fields back to the server during the save, so the new value does not actually get saved.
Any ideas would be welcome. :)
It seems the following line solves my problem:
Xrm.Page.getAttribute(d.ConstituentAffiliation.AttributeNames.Primary
.toLowerCase()).setSubmitMode("always");
So the code now reads as follows:
export function onSave() {
var primaryControl = Xrm.Page.getControl( d.ConstituentAffiliation.AttributeNames.Primary.toLowerCase());
if (primaryControl) {
if (primaryControl.getAttribute().getValue()) {
Xrm.Page.getAttribute( d.ConstituentAffiliation.AttributeNames.Primary.toLowerCase() ).setSubmitMode("always");
primaryControl.setDisabled(true);
}
else {
primaryControl.setDisabled(false);
}
}
}
I should credit this blog which was very helpful: http://blogs.msdn.com/b/arpita/archive/2012/02/19/microsoft-dynamics-crm-2011-force-submit-on-a-disabled-field-or-read-only-field.aspx
Looks like you've solved it however I was curious. Have you tried using a Business Rule? This kind of basic functionality is what Business Rules in CRM 2015 can handle quite well.
For example something like this:-

CodeIgniter - Dynamic URL segments

I was wondering if someone could help me out.
Im building a forum into my codeigniter application and im having a little trouble figuring out how i build the segments.
As per the CI userguide the uri is built as follows
www.application.com/CLASS/METHOD/ARGUMENTS
This is fine except i need to structure that part a bit different.
In my forum i have categories and posts, so to view a category the following url is used
www.application.com/forums
This is fine as its the class name, but i want to have the next segment dynamic, for instance if i have a category called 'mycategory' and a post by the name of 'this-is-my-first-post', then the structure SHOULD be
www.application.com/forums/mycategory/this-is-my-first-post
I cant seem to achieve that because as per the documentation the 'mycategory' needs to be a method, even if i was to do something like /forums/category/mycategory/this-is-my-first-post it still gets confusing.
If anyone has ever done something like this before, could they shed a little light on it for me please, im quite stuck on this.
Cheers,
Nothing is confusing in the document but you are a little bit confused. Let me give you some suggestions.
You create a view where you create hyperlinks to be clicked and in the hyperlink you provide this instruction
First Post
In the controller you can easily get this
$category = $this->uri->segment(3);
$post = $this->uri->segment(4);
And now you can proceed.
If you think your requirements are something else you can use a hack i have created a method for this which dynamically assign segments.
Go to system/core/uri.php and add this method
function assing_segment($n,$num)
{
$this->segments[$n] = $num;
return $this->segments[$n];
}
How to use
$this->uri->assign_segment(3,'mycategory');
$this->uri->assign_segment(4,'this-is-my-first-post');
And if you have error 'The uri you submitted has disallowed characters' then go to application/config/config.php and add - to this
$config['permitted_uri_chars'] = 'a-z 0-9~%.:_\-';
You could make a route that forwards to a lookup function.
For example in your routes.php add a line something like;
$route['product/(:any)/(:any)'] = "forums/cat_lookup/$1/$2";
This function would then do a database lookup to find the category.
...
public function cat_lookup($cat, $post) {
$catid = $this->forum_model->get_by_name($cat);
if ($catid == FALSE) {
redirect('/home');
}
$post_id = $this->post_model->get_by_name($post);
/* whatever else you want */
// then call the function you want or load the view
$this->load->view('show_post');
}
...
This method will keep the url looking as you want and handle any problems if the category does not exist.Don't forget you can store the category/posts in your database using underscores and use the uri_title() function to make them pretty,
Set in within config/routes.php
$route['song-album/(:any)/:num'] = 'Home/song_album/$id';
fetch in function with help of uri segment.
$this->uri->segment(1);

submitting form values in php using ajax request

okay, so I am trying to load a user's information into form fields after the user has finished creating an account. This is sort of a "re-check your personal info" but here his previously entered values are already set. How should I do so using ajax. I want to use the prototype ajax to avoid obtrusive coding.
Again,these are the steps
1.User creates an account on signUp.php
2.He is redirected to edit.php where he checks his personal info which is set by default.
if I do this
function setFormData()
{
new Ajax.requestHTML("edit.php")
{ onSuccess:someFunction()
});
}
then how can I set the form values, like
function someFuncton(ajax)
{
$("firstname").value=??
$("lastname").value=??
$("country").value=??
}
you can in the edit.php output an xml, json or string with the values, parse it and use in your someFunction

Resources