Forum Replies Created
-
AuthorPosts
-
February 22, 2022 at 23:30 in reply to: Create item in another list issue with setting value for Lookup column #35579
This is my code:
var ok = spjs.dffs.check_Mandatory([“Title”]), data = {}, newItem;
if(ok){
data.Title = getFieldValue(“Title”); //This works great since it’s a single line of text column
data.LookupColumn = getFieldValue(“Title”); //This is where I get an error I assume because it’s a lookup column
newItem = spjs.utility.addItem({“listName”:”MyGUID”,”data”:data});
if(newItem.success){
// Item added
}else{
alert(newItem.errorText);
}
}Thank you Alexander!!! I just had to change the query and it was finally picking up! THIS IS A GAME CHANGER! THANK YOUUUUUU!!!
I see.. The custom drop-down list doesn’t seem to pull in any of the templates from the template list.
Thank you Alexander! How does this function get triggered when the autocomplete field is changed?
Thanks so much Alexander! Here’s what I’m trying to do in the attachment.
Each time a template is selected, I’d like to append the text in the field to the bottom of the text box with a line break.
Attachments:
This is the message I get when I turn on multiselect.
“You cannot use the “setFields” section in the configuration when you are using the “multiselect” option.Is there a way around this?
Attachments:
Thanks Alex. For some reason it still wasn’t working with the choice field (only with a single line of text field), so I added another function set the value to the dropdown choice field and it’s working. That might not be the best way, but the only way I could get it to work.
function parseIChoice(a, fin) { var $I = $("select[title='Contact_method']"); var arr = []; // use this format with "useREST": false jQuery.each(a[0].split(";#"), function(i, v) { if (v !== "") { arr.push(v); } }); //alert(arr); $I.val(arr); return arr; }
My second question is about turning multiselect on with set field. What I’d like to do is use this autocomplete feature for “templates”. When a user selects a template, I’d like to use the set field to populate a template of a multiline text box. When I use multiselect, the set field doesn’t work. Is there a way to modify the code to allow for set field to append to the multiline text box?
I tried adding this and it didn’t work for me. Is there a way to debug it? I console logged the value and it’s picking it up, but just not setting it.
Works great! THANK YOU!!
One thing that isn’t working is the set field value from a choice field. Is there another way to get that to work?
Ah! So I updated to the latest version and I see that the list will now show the new item, but it doesn’t automatically set field values once added to the new list. Is that what you say is supposed to happen?
Also, how do you set field values for choice fields? It doesn’t seem to be passing through.
Thanks Adam!
Alexander, yes, I’ve tried it with Google Chrome and got the same Loading message.Sorry Alexander, I made a rookie mistake. The problem I was having was with the rule I set up to run the function. I changed the trigger to “is changed” and everything is working beautifully. Thank you again for your work on this! 🙂
Hi Alexander! I’ve been noticing the script gets hung up when I try to put in a date in 2019. It works when I put a date in 2018 first, and then change the date to 2019. But if I start with 2019, it gets hung up.
Do you know why that would be and how to fix it?
Thank you!
- This reply was modified 6 years, 4 months ago by Charlene.
Wrapping the code in a function and calling it from the rule worked beautifully!!!!!! THANK YOU SOOOOOOO MUCH!!!
And thank you so much for your patience with the troubleshooting! I am not very familiar with JavaScript so your notes for the console helped a TON!!
And one thing I wanted to note was that I ended up creating 2 rules because there are 2 end dates I’m working with. When I tried cloning the 1st rule, the 2nd rule didn’t work, but when I created them as new rules, the 2nd rule started working. I’m not sure if that’s a bug with the cloning feature, but wanted to bring it up in case it is.
Thanks again, Alexander!!!! Sending you a few beers for your help!!!
Thank you so much Alexander! I tried including the 1st and 2nd code you provided above in Custom JS and changed the name of the DateColumn1 to my End Date.
I was getting an error with the setFieldValue code you have above, so I inserted the following code after console.log instead.
var pl_date2 = spjs.utility.dateObjToFormattedString(pl_date,"MM/dd/yyyy"); setFieldValue("PLDateColumn",pl_date2);
The problem I’m seeing is:
1. The ‘EndDate’ is not being retrieved. It is pulling in today’s date even though I updated the DateColumn1 to the ‘EndDate’. I’d like this function to trigger when the EndDate is not null or updated and when PLDate, GTMDate, Comm1Date, Comm2Date are empty. Is that possible? Do I need to use rules or just include it all in the Custom JS? Perhaps add: if(“start” == “”){setFieldValue…};?2. The year represented is 1969 vs 2017. How do I fix this?
THANK YOU!
- This reply was modified 7 years ago by Charlene.
-
AuthorPosts